Create-react-app: npm start not working events.js174 throw er; //Unhandled 'error' event

Created on 4 May 2019  路  9Comments  路  Source: facebook/create-react-app

Is this a bug report?

yes

Did you try recovering your dependencies?

yes

Which terms did you search for in User Guide?

(Write your answer here if relevant.)

Environment

Environment Info:

System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz
Binaries:
Node: 10.15.3 - C:Program Filesnodejsnode.EXE
Yarn: Not Found
npm: 6.9.0 - C:Program Filesnodejsnpm.CMD
Browsers:
Edge: Not Found
Internet Explorer: Not Found
npmPackages:
react: ^16.8.6 => 16.8.6
react-dom: ^16.8.6 => 16.8.6
react-scripts: 3.0.0 => 3.0.0
npmGlobalPackages:
create-react-app: Not Found

Steps to Reproduce

(Write your steps here:)

  1. cd my-app
    2, npm start

  2. create-react-app my-app

  3. cd my-app
  4. npm start

or

  1. create-react-app my-app
  2. cd my-app
  3. npm start

Expected Behavior

Run the app in development mode
Open http://localhost:3000 to view it in the browser

Actual Behavior

when starting my react-app:
Capture1

when starting a newly created react app
Capture

events.js:174
throw er; // Unhandled 'error' event
^

Error: spawn cmd ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:240:19)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
Emitted 'error' event at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:246:12)
at onErrorNT (internal/child_process.js:415:16)
at process._tickCallback (internal/process/next_tick.js:63:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: react-scripts start
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.

npm ERR! A complete log of this run can be found in:
npm ERR! C:UserscaldeAppDataRoamingnpm-cache_logs2019-05-04T18_42_43_606Z-debug.log

log file:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\Program Files\nodejs\node.exe',
1 verbose cli 'C:\Users\calde\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js',
1 verbose cli 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: C:UserscaldeAppDataRoamingnpmnode_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin;C:UserscaldeDocumentsMediaprogrammingreactmazenode_modules.bin;C:Program Filesnodejs;C:UserscaldeAppDataRoamingnpm;
9 verbose lifecycle [email protected]~start: CWD: C:UserscaldeDocumentsMediaprogrammingreactmaze
10 silly lifecycle [email protected]~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 silly lifecycle [email protected]~start: Returned: code: 1 signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: react-scripts start
13 verbose stack Exit status 1
13 verbose stack at EventEmitter. (C:UserscaldeAppDataRoamingnpmnode_modulesnpmnode_modulesnpm-lifecycleindex.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:189:13)
13 verbose stack at ChildProcess. (C:UserscaldeAppDataRoamingnpmnode_modulesnpmnode_modulesnpm-lifecyclelibspawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:189:13)
13 verbose stack at maybeClose (internal/child_process.js:970:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid [email protected]
15 verbose cwd C:UserscaldeDocumentsMediaprogrammingreactmaze
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\calde\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "start"
18 verbose node v10.15.3
19 verbose npm v6.9.0
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: react-scripts start
22 error Exit status 1
23 error Failed at the [email protected] start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Reproducible Demo

https://github.com/NickCalderone/maze

Most helpful comment

I ran into this exact issue as well and found that it is only present with [email protected], downgrading to [email protected] resolved the issue without needing to mess with environment variables.

create-react-app my-app
cd my-app
npm install [email protected]
npm start

All 9 comments

I'm facing the same issue in Windows 64.
npm test, build, eject works fine and only npm start fails.

Node js project and old react projects using webpack ( "start": "webpack-dev-server --mode development --config webpack.dev.config.js") works fine as well.

What's the fix for this?

I fount the solution to my issue. It turns out I didn't have all of my default path environmental variables for windows. Check this link for the defaults and hope this helps someone else out there with the same problem.

https://www.computerhope.com/issues/ch000088.htm

I ran into this exact issue as well and found that it is only present with [email protected], downgrading to [email protected] resolved the issue without needing to mess with environment variables.

create-react-app my-app
cd my-app
npm install [email protected]
npm start

thankyou @tylerlaberge it worked for me...

I fount the solution to my issue. It turns out I didn't have all of my default path environmental variables for windows. Check this link for the defaults and hope this helps someone else out there with the same problem.

https://www.computerhope.com/issues/ch000088.htm

Hello sir. I checked out the link you pasted, but found nothing

I had this problem a few days ago and after try all the things possible, i check the that w10 has an update resolving a js bug. So i update w10 and it worked.

@JoshMatthew

the %PATH% section of the link shows the default variables in your machines PATH:
C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;

any other paths can be added to the end. Remember to have the npm paths as well:
C:Program Filesnodejs;C:Users{yourName}AppDataRoamingnpm

I felt in same problem. Thank you @tylerlaberge it worked for me...

thank you so much @tylerlaberge

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Aranir picture Aranir  路  3Comments

JimmyLv picture JimmyLv  路  3Comments

rdamian3 picture rdamian3  路  3Comments

ap13p picture ap13p  路  3Comments

fson picture fson  路  3Comments