6

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?

3
  • Works fine for me. Can you post your entire package.json? Commented Jun 5, 2017 at 23:35
  • Deleting the node_modules folder and running npm install fixed the issue. Commented Jun 6, 2017 at 19:26
  • 2
    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 ??? Commented Dec 29, 2019 at 1:02

1 Answer 1

11

Delete the node_modules folder and then run npm install.

Sign up to request clarification or add additional context in comments.

2 Comments

It still doesn't run the sample code when I run npm start
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 ???

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.