3
votes

I have the following in package.json for several electron apps:

  "name": "my-app",  
  "version": "1.0.0",  
  "description": "",  
  "main": "main.js",  
      "scripts": {
        "start": "electron ."
      },

When I'd do npm start in the app folder, the corresponding app use to run. I just started getting the following output for all of my electron apps when using npm start:

electron .

module.js:471
throw err; ^

Error: Cannot find module './'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25).
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/Users/me/electron/my-app/node_modules/.bin/electron:3:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: electron .
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is
likely additional logging output above.

However, I can do either of the following successfully on the command line:

electron main.js
electron .

Anyone know what might have broken the package.json script? Or some other suggestions?

1
Works fine for me. Can you post your entire package.json? - Ian Wise
Deleting the node_modules folder and running npm install fixed the issue. - 4thSpace
should i be able to execute electron index.js or electron . in command prompt? i get the following error, 'electron' is not recognized as an internal or external command, operable program or batch file, obviously due to Electron not being set to path. but i never needed to set Electron to path before ??? - oldboy

1 Answers

10
votes

Delete the node_modules folder and then run npm install.