build-tools: Cannot find module after installing @electron/build-tools on Arch

internal/modules/cjs/loader.js:895
  throw err;
  ^

Error: Cannot find module '/home/ross/.electron_build_tools/src/e'
Require stack:
- /usr/lib/node_modules/@electron/build-tools/run.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)
    at Function.Module._load (internal/modules/cjs/loader.js:742:27)
    at Module.require (internal/modules/cjs/loader.js:964:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/usr/lib/node_modules/@electron/build-tools/run.js:15:1)
    at Module._compile (internal/modules/cjs/loader.js:1075:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1096:10)
    at Module.load (internal/modules/cjs/loader.js:940:32)
    at Function.Module._load (internal/modules/cjs/loader.js:781:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/lib/node_modules/@electron/build-tools/run.js' ]
}

I just ran npm install -g @electron/build-tools on Arch LInux and got this error after rehashing in zsh and running e init --root=~/electron --bootstrap testing.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 1
  • Comments: 22 (4 by maintainers)

Most upvoted comments

A solution I came up with:

git clone https://github.com/electron/build-tools ~/.electron_build_tools && (cd ~/.electron_build_tools && npm install)

I also suffered this issue. And I found out that

  1. uninstalling build-tools from npm
  2. install yarn
  3. install build-tools again

resolved my issue. If other people confirms that it is resolved by installing yarn, I suggests to modify README.md to state yarn to be ‘must install’ rather than ‘recommend installing’.

I also have this issue. I’ve tried npm i -g, but when I try to run e, it looks in my home directory instead of in /usr/lib:

[levi@arch-vm build-tools]$ e init --help
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '/home/levi/.electron_build_tools/src/e'
Require stack:
- /usr/lib/node_modules/@electron/build-tools/run.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/usr/lib/node_modules/@electron/build-tools/run.js:15:1)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/usr/lib/node_modules/@electron/build-tools/run.js' ]
}

Node.js v17.3.0

Installing a copy in my user’s home directory seems to have resolved the issue.