`ERR_REQUIRE_ESM` error when trying to install electron
See original GitHub issueWhen trying to install electron using:
pnpm install electron --save-dev
I get the error:
EACCES EACCES: permission denied, mkdir '/node_modules/.pnpm/global-agent@3.0.0/node_modules/_tmp_86012_2f2ba15245ff2a054dcb4fa80c2b849f
So I try with sudo::
sudo pnpm install electron --save-dev
Yet get the following error:
node_modules/.pnpm/electron@20.1.1/node_modules/electron: Running postinstall script, failed in 157ms
.../node_modules/electron postinstall$ node install.js
│ Error [ERR_REQUIRE_ESM]: require() of ES Module /node_modules/.pnpm/got@12.4.1/node_modules/got/dist/source/index.js from /node_modules/.pnpm/@electron+get@1.14.1/node_modules/@electron/get/dist/cjs/GotDow
│ Instead change the require of index.js in /node_modules/.pnpm/@electron+get@1.14.1/node_modules/@electron/get/dist/cjs/GotDownloader.js to a dynamic import() which is available in all CommonJS modules.
│ at Object.<anonymous> (/node_modules/.pnpm/@electron+get@1.14.1/node_modules/@electron/get/dist/cjs/GotDownloader.js:15:13)
│ at /node_modules/.pnpm/@electron+get@1.14.1/node_modules/@electron/get/dist/cjs/downloader-resolver.js:8:66
│ at async Object.getDownloaderForSystem (/node_modules/.pnpm/@electron+get@1.14.1/node_modules/@electron/get/dist/cjs/downloader-resolver.js:8:31)
│ at async /node_modules/.pnpm/@electron+get@1.14.1/node_modules/@electron/get/dist/cjs/index.js:67:59
│ at async useAndRemoveDirectory (/node_modules/.pnpm/@electron+get@1.14.1/node_modules/@electron/get/dist/cjs/utils.js:10:18)
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Error: Electron failed to install correctly, please delete ... - GitHub
Apparently little hard joy. electron@1.4.15 postinstall C:\Users\Lizandro Zerpa\AppData\Roaming\npm\node_modules\electron node install.js.
Read more >Error [ERR_REQUIRE_ESM]: How to use es6 modules in ...
Try using npm's esm module which will support es6 (It can also be used in production).
Read more >Must use import to load ES Module: : r/electronjs - Reddit
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: I'm trying to make a minimal electron application, with just a web view.
Read more >Error [ERR_REQUIRE_ESM]: require() of ES Module not ...
The error [ERR_REQUIRE_ESM]: require() of ES Module not supported. Instead change the require of index.js to a dynamic import() which is available in...
Read more >Error ERR REQUIRE ESM | Must use import to load ES Module
Your browser can't play this video. Learn more. Switch camera.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Issue has been resolved by removing the “pnpm.overrides” from package.json. It would be solved 100% if electron/get would use the latest GOT version but this might not be doable due to incompatibilities.
Seems another package in combination with pnpm audit added this because of known security issues:
Which might have caused the above issue.