sh: react-scripts: command not found after running npm start

The Error “sh: react-scripts: command not found after running npm start”, is an error that is invoked when you are coding on react.js and are working on a react application.

Given below is the snippet of the error you might get:

sh: react-scripts: command not found after running npm start

I would like to share with you the steps I took to fix the “sh: react-scripts: command not found after running npm start”

Why “sh: react-scripts: command not found after running npm start” Error is Seen?

The error, “sh: react-scripts: command not found after running npm start” is seen because node_modules directory is not seen in your project directory as it does not exist. There won’t likely be any node modules after a fresh clone because these are .gitignore’d.

This also occurs if you attempt to perform npm install after the project has been setup using Yarn.

They are incompatible with one another, so this will not work. A Yarn-generated tree will become corrupted if npm install is run on top of it.

The detailed solution to fix the error ” sh: react-scripts: command not found after running npm start”, is given below:

How to Fix “sh: react-scripts: command not found after running npm start” Error?

To fix the error, “sh: react-scripts: command not found after running npm start” you will have to make sure all dependencies are downloaded, use yarn or npm install. Alternatively, run ‘rm -rf node modules’ to remove it if node modules already exists, and then type npm install (or yarn).

To fix the error, “sh: react-scripts: command not found after running npm start”, you will have to follow the steps mentioned below:

The error is seen because node_modules directory is not seen in your project directory because it does not exist. To fix this you will have to make sure all dependencies are downloaded, use yarn or npm install

If the above solution does not work alternatively you can try to run rm -rf node modules to remove it if node modules already exists, and then type npm install (or yarn).

Note: Make sure to always add packages using yarn add and to remove node modules to avoid this error in the future

This should fix the error “sh: react-scripts: command not found after running npm start”.

Conclusion

To fix the error, “sh: react-scripts: command not found after running npm start” you will have to make sure all dependencies are downloaded, use yarn or npm install.

Alternatively, run rm -rf node modules to remove it if node modules already exists, and then type npm install (or yarn).