title: How can I make the ESM work with electron in my project?
body: <p>I've been trying fix for this a week now but can't really seem to find the problem. </p>
  
  <p>I've followed <a href="https://stackoverflow.com/a/53569631/2464270">this tutorial</a> but instead of having that project structure I've my own (see image below) </p>
  
  <p><a href="https://i.stack.imgur.com/AEiby.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AEiby.png" alt="Project structure"></a></p>
  
  <p>In the <em>esm.js</em>: </p>
  
  <pre><code>require = require("esm")(module);
  module.exports = require("./vickie.js");
  </code></pre>
  
  <p>Then i've changed <em>vickie.js</em>: <br> 
  From <code>const { app, BrowserWindow, ipcMain } = require('electron')</code> <br> 
  To <code>import { app, BrowserWindow, ipcMain } from 'electron'</code></p>
  
  <p>Then I got this error </p>
  
  <p><a href="https://i.stack.imgur.com/7Gn5N.png" rel="noreferrer"><img src="https://i.stack.imgur.com/7Gn5N.png" alt="Electron error"></a></p>
  
  <p>In <em>package.json</em>: </p>
  
  <pre><code>{
    "name": "vickie",
    "type": "module",
    "version": "0.0.1",
    "description": "",
    "main": "./vickie.js",
    "scripts": {
      "start": "electron ./vickie.js"
    },
    "author": "Arijanit",
    "license": "ISC",
    "devDependencies": {},
    "dependencies": {
      "dotenv": "^8.2.0",
      "electron": "^8.2.3",
      "electron-builder": "^22.5.1",
      "esm": "^3.2.25",
      "mysql2": "^1.7.0"
    }
  }
  </code></pre>
  
  <p>Why am I getting the error? Should I type in something extra in <em>package.json</em> to enable esm? </p>
  
  <p>Thanks in advance </p>