npm start error with create-react-app

JavascriptReactjsCreate React-App

Javascript Problem Overview


I have a project who I didn't touch for 2 weeks. I take it back and now when I try to run npm start I got this error.

> react-scripts start

sh: react-scripts: command not found

npm ERR! Darwin 16.0.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.7.0
npm ERR! npm  v3.10.3
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! UpScore@0.6.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the UpScore@0.6.0 start script 'react-scripts start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the UpScore package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     react-scripts start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs UpScore
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls UpScore
npm ERR! There is likely additional logging output above.
  • node 6.7.0
  • npm 3.10.3
  • mac sierra 10.12

package.json

{
  "name": "UpScore",
  "version": "0.6.0",
  "private": true,
  "devDependencies": {
    "react-addons-test-utils": "^15.3.1",
    "react-scripts": "0.4.1",
    "react-test-renderer": "^15.3.1",
    "redux-logger": "^2.6.1"
  },
  "dependencies": {
    "@yoshokatana/medium-button": "^1.1.0",
    "axios": "^0.14.0",
    "bcrypt": "^0.8.7",
    "bcrypt-nodejs": "0.0.3",
    "bcryptjs": "^2.3.0",
    "body-parser": "^1.15.2",
    "connect-flash": "^0.1.1",
    "cookie-parser": "^1.4.3",
    "draft-js": "^0.8.1",
    "draft-js-editor": "^1.7.2",
    "draft-js-export-html": "^0.4.0",
    "ejs": "^2.5.2",
    "email-verification": "^0.4.5",
    "express": "^4.14.0",
    "express-session": "^1.14.1",
    "flexboxgrid": "^6.3.1",
    "highlight.js": "^9.6.0",
    "immutable": "^3.8.1",
    "katex": "^0.6.0",
    "lodash": "^4.15.0",
    "markdown-it-mathjax": "^1.0.3",
    "material-ui": "^0.15.4",
    "medium-editor": "^5.22.0",
    "minutes-seconds-milliseconds": "^1.0.3",
    "moment": "^2.15.0",
    "moment-duration-format": "^1.3.0",
    "mongod": "^1.3.0",
    "mongodb": "^2.2.9",
    "mongoose": "^4.6.0",
    "monk": "^3.1.2",
    "morgan": "^1.7.0",
    "normalize.css": "^3.0.3",
    "passport": "^0.3.2",
    "passport-local": "^1.0.0",
    "react": "^15.3.1",
    "react-dom": "^15.3.1",
    "react-markdown": "^2.4.2",
    "react-medium-editor": "^1.8.1",
    "react-redux": "^4.4.5",
    "react-redux-form": "^0.14.5",
    "react-rich-markdown": "^1.0.1",
    "react-router": "^2.7.0",
    "react-router-redux": "^4.0.5",
    "react-tap-event-plugin": "^1.0.0",
    "react-tinymce": "^0.5.1",
    "redux": "^3.6.0",
    "redux-form": "^6.0.5",
    "redux-form-material-ui": "^4.0.1",
    "redux-promise-middleware": "^4.0.0",
    "redux-thunk": "^2.1.0",
    "reselect": "^2.5.3",
    "screenfull": "^3.0.2"
  },
  "scripts": {
    "start": "react-scripts start",
    "start:prod": "pushstate-server build",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject",
    "server": "cd client/api && pm2 start server.js --watch",
    "proxy": "http://128.199.139.144:3000"
  },
  "eslintConfig": {
    "extends": "./node_modules/react-scripts/config/eslint.js"
  }
}

I try to clone my repos too and get the same error. If someone can give me some way to find what happen. Thank you

Javascript Solutions


Solution 1 - Javascript

Author of Create React App checking in.

You absolutely should not be installing react-scripts globally.
You also don't need ./node_modules/react-scripts/bin/ in package.json as this answer implies.

If you see this:

npm ERR! UpScore@0.6.0 start: `react-scripts start`
npm ERR! spawn ENOENT

It just means something went wrong when dependencies were installed the first time.

I suggest doing these three steps:

  1. npm install -g npm@latest to update npm because it is sometimes buggy.
  2. rm -rf node_modules to remove the existing modules.
  3. npm install to re-install the project dependencies.

This should fix the problem.
If it doesn't, please file an issue with a link to your project and versions of Node and npm.

Solution 2 - Javascript

It seems like you don't have react-scripts in your global environment. Two possibility are available here :

npm install -g react-scripts

or in your package.json change your script part like this :

  "scripts": {
    "start": "./node_modules/react-scripts/bin/react-scripts.js start",
    "start:prod": "pushstate-server build",
    "build": "./node_modules/react-scripts/bin/react-scripts.js build",
    "test": "./node_modules/react-scripts/bin/react-scripts.js test --env=jsdom",
    "eject": "./node_modules/react-scripts/bin/react-scripts.js eject",
    "server": "cd client/api && pm2 start server.js --watch",
    "proxy": "http://128.199.139.144:3000"
  },

Solution 3 - Javascript

Yes you should not install react-scripts globally, it will not work.

I think i didn't use the --save when i first created the project (on another machine), so for me this fixed the problem :

npm install --save react react-dom react-scripts

Solution 4 - Javascript

incase you happened to be so unlucky like me that spent three(3) days in a row trying to solve this problem every solution proposed here failed me ... create a .env file in your project root and add this code SKIP_PREFLIGHT_CHECK=true. Good luck

Solution 5 - Javascript

This is to help others completely new to react and who area having problems just starting a first app even though they did a fresh install and try using npm install and the other fixes I saw around the forums.

Running it on Windows 10 with all the latest npm create-react-app installed and got failure after failure on a simple npm start in a simple my-app demo folder.

Spent a long time with what looks similar to the OP error at first but is slightly different. This starts with ERRNO 4058 and continues with code 'ENOENT' syscall: 'spawn cmd', path: ''cmd' ...

Eventually worked out from github create-react-app forum that a quick fix for this is registering cmd in the "path" variable. To do this go to System Properties>Environment variables. Click on path variable edit and and add new entry of C:\Windows\System32. Restart CMD prompt and I was good to go.

Solution 6 - Javascript

As Dan said correctly, >If you see this:

npm ERR! UpScore@0.6.0 start: `react-scripts start`
npm ERR! spawn ENOENT

>It just means something went wrong when dependencies were installed the first time.

But I got something slightly different because running npm install -g npm@latest to update npm might sometimes leave you with this error:

npm ERR! code ETARGET
npm ERR! notarget No matching version found for npm@lates
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

so, instead of running npm install -g npm@latest, I suggest running the below steps:

 npm i -g npm //which will also update npm
 rm -rf node_modules/ && npm cache clean // to remove the existing modules and clean the cache.
 npm install //to re-install the project dependencies.

This should get you back on your feet.

Solution 7 - Javascript

I might be very late to answer this question but this is what has worked for me and it might help someone to get back on the development track!

nvm install v12.0 // You may need to install nvm, if not already done
rm -rd node_modules/
npm cache clean --force
npm install

Cheers!!

Solution 8 - Javascript

For me it was simply that I hadn't added react-scripts to the project so:

npm i -S react-scripts

If this doesn't work, then rm node_modules as suggested by others

rm -r node_modules
npm i

Solution 9 - Javascript

I have faced the following issue.

enter image description here

Please find the solution:

  1. Add "C:\Windows\System32" to the global PATH environment variable.

  2. Check whether the environment variables has been created for nodejs,npm and composer. if not create one

enter image description here

  1. Run your app.

Solution 10 - Javascript

I had the same error when running

> npm start

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! protest-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the protest-app@0.1.0 start script.

I broke my head on several tabs and applying Solutions from other devs and nothing.

Until, even using Ubuntu, I closed my vscode and restarted my pc and all my problems were solved. (kkkk zueira) just this one.

Solution 11 - Javascript

add environment variables in windows

  1. C:\WINDOWS\System32

  2. C:\Program Files\nodejs

  3. C:\Program Files\nodejs\node_modules\npm\bin

  4. C:\WINDOWS\System32\WindowsPowerShell\v1.0

  5. C:\Users{your system name without curly braces}\AppData\Roaming\npm

these 5 are must in path.

and use the latest version of node.js

Solution 12 - Javascript

I solve this issue by running following command

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

hope it helps

Solution 13 - Javascript

Add .env file with "SKIP_PREFLIGHT_CHECK=true" than npm start

Solution 14 - Javascript

I fix this using this following command:

npm install -g react-scripts

Solution 15 - Javascript

it is simple but the first time it takes time a few steps to set !!!

  1. you have the latest version on node.

  2. go to the environment variable and set the path "%SystemRoot%\system32".

enter image description here

  1. run cmd as administrator mode.

  2. write command npm start.

Solution 16 - Javascript

i ran npm install inside the project then npm start it worked

Solution 17 - Javascript

just delete the "node_module" file and if its seems somehow grey in folder that means it's not there just close the vs code and re open then

install npm with "npm install".

Solution 18 - Javascript

it's possible that conflict with other library, delete node_modules and again npm install.

Solution 19 - Javascript

This occurs when the node_modules gets out of sync with package.json.

Run the following at the root and any sub service /sub-folder that might have node_modules folder within it.

rd node_modules /S /Q
npm install

Solution 20 - Javascript

It occurred to me but none of the above worked.

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

npm ERR! UpScore@0.6.0 start: `react-scripts start`
npm ERR! spawn ENOENT

Error: spawn ENOENT
    at errnoException (child_process.js:1000:11)
    at Process.ChildProcess._handle.onexit (child_process.js:791:34)

This happens because you might have installed react-scripts globally.

To make this work...

  1. Go to your C:\Users\<USER>\AppData\Roaming
  2. Delete npm and npm-cache directories... (don't worry you can install npm globally later)
  3. Go back to your application directory and remove node_modules folder
  4. Now enter npm install to install the dependencies (delete package-lock.json if its already created)
  5. Now run npm install --save react react-dom react-scripts
  6. Get it started with npm start

This should get you back on track... Happy Coding

Solution 21 - Javascript

My issue was stemming from permission issues. I solved mine by following this https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

Solution 22 - Javascript

Type unset HOST in your terminal.

Solution 23 - Javascript

I have created react project locally. This reason of occurring this problem (for me) was that I didn't use sudo before npm and it needs root access (

> sudo npm start

PS1: For windows users, the powershell or command line should be run as administrator)

PS2: If use want to solve the root access issue, you can see this post.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEQuimperView Question on Stackoverflow
Solution 1 - JavascriptDan AbramovView Answer on Stackoverflow
Solution 2 - JavascriptSteeve PitisView Answer on Stackoverflow
Solution 3 - JavascriptChtiwi MalekView Answer on Stackoverflow
Solution 4 - JavascriptFlavinsView Answer on Stackoverflow
Solution 5 - JavascriptTony_GRView Answer on Stackoverflow
Solution 6 - JavascriptantzshrekView Answer on Stackoverflow
Solution 7 - JavascriptLearnerView Answer on Stackoverflow
Solution 8 - JavascriptJamie HutberView Answer on Stackoverflow
Solution 9 - JavascriptGopinath gopsView Answer on Stackoverflow
Solution 10 - JavascriptRodrigo StuaniView Answer on Stackoverflow
Solution 11 - JavascriptPramod UkkaliView Answer on Stackoverflow
Solution 12 - JavascriptKrishna JangidView Answer on Stackoverflow
Solution 13 - JavascriptAakash HandaView Answer on Stackoverflow
Solution 14 - JavascriptUsama MajidView Answer on Stackoverflow
Solution 15 - Javascriptvikky singhView Answer on Stackoverflow
Solution 16 - JavascriptTATView Answer on Stackoverflow
Solution 17 - JavascriptArif Khan KhaishagiView Answer on Stackoverflow
Solution 18 - JavascriptDiego Santa Cruz MendezúView Answer on Stackoverflow
Solution 19 - JavascriptChizlView Answer on Stackoverflow
Solution 20 - JavascriptAmirtha RajanView Answer on Stackoverflow
Solution 21 - JavascriptbvmcodeView Answer on Stackoverflow
Solution 22 - JavascriptAbhijith Neil AbrahamView Answer on Stackoverflow
Solution 23 - JavascriptMostafa GhadimiView Answer on Stackoverflow