How to fix the react-scripts command not found Error
In this tutorial, we are going to learn about how to solve the sh: react-scripts: command not found error after running the npm start command.
When you are trying to run an npm start
command on a cloned react project sometimes you probably see this type of error in your terminal.
sh: react-scripts: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! react-track@0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the react-track@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/saigowtham/.npm/_logs/2020-07-26T23_40_42_563Z-debug.log
This error occurs due to a node_modules
folder doesn’t present in your project or package-lock.json
file is corrupted.
To fix this error, follow the below steps.
- First, delete the
node_modules
folder in your project (if you have one) using the below command.
rm -rf node_modules
- Delete the
package-lock.json
file.
rm -rf package-lock.json
- Install the project dependencies by running the following command.
npm install
- Now, try to start the development server again using the
npm start
command it will work successfully without any errors.
Compiled successfully!
You can now view react-track in the browser.
Local: http://localhost:3000
On Your Network: http://192.168.1.3:3000
Note that the development build is not optimized.
To create a production build, use npm run build.