Reputation: 5929
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! [email protected] start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] 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.
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
Upvotes: 108
Views: 334913
Reputation: 311
for me I create a .env file in the project root and after that I write one line SKIP_PREFLIGHT_CHECK=true. It work for me
Upvotes: 0
Reputation: 71
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".
Upvotes: 1
Reputation: 157
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!!
Upvotes: 5
Reputation: 281
add environment variables in windows
these 5 are must in path.
and use the latest version of node.js
Upvotes: 2
Reputation: 6736
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.
Upvotes: 0
Reputation: 446
it is simple but the first time it takes time a few steps to set !!!
you have the latest version on node.
go to the environment variable and set the path "%SystemRoot%\system32"
.
run cmd as administrator mode.
write command npm start.
Upvotes: 1
Reputation: 31
I had the same error when running
npm start
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.
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.
Upvotes: 2
Reputation: 47
I have faced the following issue.
Please find the solution:
Add "C:\Windows\System32" to the global PATH environment variable.
Check whether the environment variables has been created for nodejs,npm and composer. if not create one
Upvotes: 2
Reputation: 1274
I fix this using this following command:
npm install -g react-scripts
Upvotes: 1
Reputation: 1307
Add .env file with "SKIP_PREFLIGHT_CHECK=true" than npm start
Upvotes: 1
Reputation: 2472
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
Upvotes: 0
Reputation: 635
It occurred to me but none of the above worked.
events.js:72
throw er; // Unhandled 'error' event
^
npm ERR! [email protected] 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...
C:\Users\<USER>\AppData\Roaming
node_modules
foldernpm install
to install the dependencies (delete package-lock.json if its already created)npm install --save react react-dom react-scripts
npm start
This should get you back on track... Happy Coding
Upvotes: 0
Reputation: 5410
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
Upvotes: 1
Reputation:
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
Upvotes: 0
Reputation: 81
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.
Upvotes: 6
Reputation: 143
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
Upvotes: 9
Reputation: 28076
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
Upvotes: 2
Reputation: 9933
As Dan said correctly,
If you see this:
npm ERR! [email protected] 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.
Upvotes: 5
Reputation: 4651
it's possible that conflict with other library, delete node_modules and again npm install.
Upvotes: 0
Reputation: 11515
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
Upvotes: 10
Reputation: 268255
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! [email protected] 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:
npm install -g npm@latest
to update npm because it is sometimes buggy.rm -rf node_modules
to remove the existing modules.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.
Upvotes: 284
Reputation: 4443
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"
},
Upvotes: 17