create-react-app: npm start not working, react-scripts not found
Run these steps in this order
rm -rf node_modules (or if this does not work remove with the force flag rm -rf node_modules -- force
rm ./package-lock.json (or if this does not work try) rm .\package-lock.json
npm run clean (or if this does not work) npm cache clean (or if this does not work) npm cache clean --force
npm install -g npm@latest
npm uninstall -g create-react-app npm install -g create-react-app
If the create react-app does not work reinstall npm install --save react react-dom react-scripts (and any other dependencies)
Work_Work
Updated on June 05, 2022Comments
-
Work_Work almost 2 years
NPM start does not work.
Node: v12.6.0 npm: 6.10.0
Note: I put the project directory into the Trash, and ran
npm start
in there and it worked. Does anyone have any idea why it's working?What I've tried:
- Used initialization commands as given by create-react-app:
npx create-react-app my-app cd my-app npm start
installed the latest version of npm
installed the latest version of node
reinstalled node modules
deleted node and npm and reinstalled
sh: react-scripts: command not found 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. 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! /Users/work/.npm/_logs/2019-07-09T16_26_11_301Z-debug.log
npm ls react
{ "name": "new", "version": "0.1.0", "private": true, "dependencies": { "react": "^16.8.6", "react-dom": "^16.8.6", "react-scripts": "3.0.1" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" }, "eslintConfig": { "extends": "react-app" }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [ "last 1 chrome version", "last 1 firefox version", "last 1 safari version" ] } }
Full Error Log
0 info it worked if it ends with ok 1 verbose cli [ 1 verbose cli '/Users/work/.nvm/versions/node/v12.6.0/bin/node', 1 verbose cli '/Users/work/.nvm/versions/node/v12.6.0/bin/npm', 1 verbose cli 'start' 1 verbose cli ] 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: /Users/work/.nvm/versions/node/v12.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/work/Documents/Summer_2019_Study/Node/odin-node/Project2:MiniMessageBoard/frontend/new/new/node_modules/.bin:/usr/local/mysql/bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Users/work/.nvm/versions/node/v12.6.0/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Postgres.app/Contents/Versions/latest/bin 9 verbose lifecycle [email protected]~start: CWD: /Users/work/Documents/Summer_2019_Study/Node/odin-node/Project2:MiniMessageBoard/frontend/new/new 10 silly lifecycle [email protected]~start: Args: [ '-c', 'react-scripts start' ] 11 info lifecycle [email protected]~start: Failed to exec start script 12 verbose stack Error: [email protected] start: `react-scripts start` 12 verbose stack spawn ENOENT 12 verbose stack at ChildProcess.<anonymous> (/Users/work/.nvm/versions/node/v12.6.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18) 12 verbose stack at ChildProcess.emit (events.js:203:13) 12 verbose stack at maybeClose (internal/child_process.js:1021:16) 12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) 13 verbose pkgid [email protected] 14 verbose cwd /Users/work/Documents/Summer_2019_Study/Node/odin-node/Project2:MiniMessageBoard/frontend/new/new 15 verbose Darwin 17.7.0 16 verbose argv "/Users/work/.nvm/versions/node/v12.6.0/bin/node" "/Users/work/.nvm/versions/node/v12.6.0/bin/npm" "start" 17 verbose node v12.6.0 18 verbose npm v6.10.0 19 error file sh 20 error code ELIFECYCLE 21 error errno ENOENT 22 error syscall spawn 23 error [email protected] start: `react-scripts start` 23 error spawn ENOENT 24 error Failed at the [email protected] start script. 24 error This is probably not a problem with npm. There is likely additional logging output above. 25 verbose exit [ 1, true ]
react-scripts won't install even after trying several times
What can I do now?
I am thinking there is an error with Node. I have both a /usr/local npm file as well as an npm file within nvm folder.
-
Galanthus almost 5 years@Gutter_prince please, make sure that you accept my answer if this works for you. Thanks!
-
Work_Work almost 5 yearsI am attempting now. I don't seem to have permission to install globally, so I am thinking that my permissions are wrong.
-
Galanthus almost 5 yearsAh, are you on mac or linux?
-
Galanthus almost 5 yearsTry: sudo npm install -g create-react-app it will ask for your user password.
-
Work_Work almost 5 yearsThat didn't work unfortunately. I may delete and reinstall node.
-
Galanthus almost 5 yearsWhat version of node do you use? Try installing the latest node and npm, remove all node_modules and try the steps from above again. if that doesn't work share the error log so I can check.
-
Galanthus almost 5 yearsRemove the folder completely, create a new folder and open this folder in CMD. run npm install create-react-app && npm init react-app my-app i have tested it right now works for me. also what is the log output for command: history
-
Galanthus almost 5 yearsAh, maybe i see what is wrong. You have installed node 12.6.0 remove it and install the recommend version.
-
Work_Work almost 5 yearsSame error after running those commands. I will have to delete and reinstall node and npm. Hopefully that will help.
-
Galanthus almost 5 yearsHope so! i have the recommend version installed this works just fine.
-
Work_Work almost 5 yearsStill doesn't work. It was working only a few weeks ago. I have no idea what's happening. Anyways, thanks for your help.