sh: react-scripts: command not found – How To Solve This?

Good day, guys! What’s up, everyone? I hope you’re all doing well. I’m attempting to run my project on another system today, but when I execute the “npm start command sh”, I get the error messages: “react-scripts: command not found in Reactjs”. As a result, I will go over all of the effective solutions with you right now.

Let’s scroll down and get started on fixing this issue right now!

What Causes the sh: react-scripts: command not found Error?

I’m attempting to launch my project on a different device, but I encounter error messages when executing the npm start command.

How Do I Fix The Error sh: react-scripts: command not found?

1. sh: react-scripts: command not found

If you come across the error “sh: react-scripts: command not found” when trying to run a project or a module that’s hosted on Github, chances are – it’s because you’re missing some required dependencies. But don’t worry, all is not lost! 

To verify that all dependencies are obtained, remove node modules and run npm install (or yarn) afterward. Run this command to remove the node modules folder. Alternatively, you may manually remove the file node_modules folder: rm -rf node_modules. 

Then, to confirm all dependencies are obtained, run npm install: install npm. You may now execute your project with the following command: Start npm right now and fix your problem.

2. How Do I Fix The Error sh: react-scripts: command not found?

To fix the error “sh: react-scripts: command not found”, simply use the “command npm I react-scripts” to run react-scripts. Then, utilizing the “npm start command”, try to execute your project. Your problem should now be resolved.

Solution 1: Remove node_modules

If you want to test out any of the projects on your machine, you need first remove the node_modules folder to use npm install (or yarn) to obtain all dependencies. Just use “rm -rf node_modules” or manually remove the node modules folder.

Next, run “npm install” to confirm all dependencies obtained.

With this command, you may now execute the project.

Now, the error should be fixed.

Solution 2: Install react-scripts

Simply run the command to set up react-scripts.

npm i react-scripts

Next, use the “npm start command” and attempts to access the project. Your problem should now be resolved.

Solution 3: In The Package.json File, Replace This Line

Update the line below in the package.json file.

"start": "react-scripts start"

In place of,

"start": "NODE_ENV=production node_modules/react-scripts/bin/react-scripts.js start"

You may now launch your project without encountering any problems.

Solution 4: Use This Command

You can also fix this error by just running this command.

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

Your problem should be OK now.

Conclusion

We hope you enjoyed our article about fixing the error sh: react-scripts: command not found. If you have any other questions or concerns, please feel free to leave a comment. We are always excited when our posts can provide useful information!

Scroll to Top