question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`ERR_REQUIRE_ESM` error when trying to install electron

See original GitHub issue

When 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:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
keganlancecommented, Sep 8, 2022

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.

1reaction
keganlancecommented, Sep 6, 2022

Seems another package in combination with pnpm audit added this because of known security issues:

  "pnpm": {
    "overrides": {
      "got@<11.8.5": ">=11.8.5"
    }
  }

Which might have caused the above issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found