0

I've tried to install Electron with npm on my computer these days, and it's installation is successful, but when I tried to run Electron, I get an error.

Here are my commands in the Windows Terminal:

PS [user profile location]> npm install -g electron

added 91 packages in 7s
PS [user profile location]> electron
node:internal/modules/cjs/loader:959
  throw err;
  ^

Error: Cannot find module '[node js location]\node_modules\electron\cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Module._load (node:internal/modules/cjs/loader:804:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.7.0
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
xzx7131
  • 23
  • 6

2 Answers2

0

Try adding the command electron . on the package.json, like this

"scripts": {
  "start": "electron .",
},

then execute npm run start

  • 1
    Thanks, I've tried that command too.But the same error still exists. – xzx7131 Aug 02 '22 at 05:03
  • @xzx7131 A made a little research and someone says that is a node misconfiguration, specifically with the node environment variable [StackOverflow link where read about it](https://stackoverflow.com/questions/24721903/npm-npm-cli-js-not-found-when-running-npm) – Hector David Rodriguez Aguilar Aug 02 '22 at 18:00
0

I have this same error too, I did a yarn install (npm install if you're using npm)

Once that finished I did yarn start or (npm start if you're using npm)

Here we go again
  • 465
  • 4
  • 13