If you are new to JavaScript or React, you may see the error sh: react-scripts: command not found. This happens a lot when you copy a project from GitHub and try to start it with npm start. It stops your app from running and can take time to fix. In this guide, we explain why it occurs and show simple ways to solve it. We use tips from developers around the world, based on top sources that share clear reasons and fixes.

React is great for making web pages, but small setup problems like this are common for starters. The error means some key files are missing or not matching in your project. Let’s look at it step by step so you can fix it quickly.
Understanding Why sh: react-scripts: command not found Appears
The sh: react-scripts: command not found error appears in your command window when your computer can’t find the react-scripts tool. This tool is important for React apps made with create-react-app. It helps start the app, build it, and test it.

From looking at popular help sites, this error is common because it solves a big problem for coders. For instance, Stack Overflow posts show that copying projects without adding files causes it. Medium stories talk about setup on different computers, and Codedamn guides focus on lasting fixes. These sites do well by giving easy, step-by-step help that new learners like1.
Common Causes of the Error
Coders see this when using someone else’s code. Here are the main reasons:
- Missing node_modules Folder: When you copy a project, this folder is often left out on purpose. Without it, react-scripts not found will happen.
- Dependency Installation Issues: If you forget to run npm install or yarn after copying, tools like react-scripts are not there. This links to npm install issue.
- Package Manager Mismatch: Changing between npm and Yarn can mess up files, causing yarn start error.
- Path and Environment Problems: Odd letters, spaces, or big letters in folder names can confuse the system, mainly on Mac or Linux. This ties to react-scripts path error.
- Global vs Local Installation: React-scripts works best inside your project, not everywhere on your computer. Wrong setup leads to react-scripts installation error.
- Corrupted Files: A broken package-lock.json or yarn.lock file can cause corrupted package-lock.json, so scripts don’t work.
Numbers show thousands face this each month. Looks for npm start error go up for new coders, based on search data. Knowing why helps stop it next time.
For more on tech help, see our guide on virtual phone numbers for safe coding spaces.
Step-by-Step Fixes for sh: react-scripts: command not found
No need to worry—this error has easy fixes with basic commands. Start with simple ones and try harder if needed. Always be in your project’s main folder.
1. Run npm install to Restore Dependencies
This is the best fix from top Stack Overflow answers, liked by over 700 people for working well.
- Delete Existing node_modules: If it’s there but old, take it away to stop problems. Use rm -rf node_modules on Mac or Linux, or remove it by hand on Windows.
- Install Dependencies: Type npm install. This gets all needed files from package.json, like react-scripts.
- Start the App: Try npm start now. If it runs, good! This solves missing dependencies react in most copied projects.
If you like Yarn, type yarn install to skip npm vs yarn dependency issues.
Tip: After copying, look for a yarn.lock file. If it’s there, use Yarn to avoid dependency conflict in React.
2. Explicitly Install react-scripts
If that doesn’t help, add the tool right away—a way liked in Medium help guides2.
- Type npm install react-scripts –save. This puts it in your needs list.
- For use everywhere (but not best for projects), type npm install -g react-scripts.
- Change package.json if you must: Make sure “scripts” has “start”: “react-scripts start”.
This fixes react-scripts missing after cloning GitHub project by making sure the tool is ready.
3. Check and Fix Folder Paths
Folder names can hide problems, as users say on many sites.
- Rename Folders: Skip spaces, odd signs like &, @, or big letters. Change “My React App” to “my-react-app”.
- Verify Directory: Type pwd on Unix or use cd to check your spot.
- Cross-Platform Tips: On Windows, try WSL for Unix feel. Mac users, note big and small letters matter.
This stops shell command not recognized tied to computer types.
For tech tips, read our post on protect your phone number online to keep your accounts safe.
4. Handle Package Manager Conflicts
If you switched between npm and Yarn:
- Take away lock files: Remove package-lock.json and yarn.lock.
- Pick one tool: Type npm install or yarn install.
- Clean Cache: Type npm cache clean –force for a new start.
This fixes package.json script not working by matching your setup.
5. Reinitialize and Update the Project
For hard cases, as Codedamn says for lasting fixes:
- Type npm init to freshen package.json.
- Update all: npm update.
- Add react-scripts again if needed.
Don’t change package.json by hand to avoid react build script error.
6. Environment Variable Adjustments
Wrong paths can hide commands.
- On Windows: Go to System Properties > Environment Variables > Edit Path. Add your npm folder, like C:\Users\YourName\AppData\Roaming\npm.
- On Mac or Linux: Change .bash_profile or .zshrc: Add export PATH=”$PATH:~/npm-global/bin”. Reload with source ~/.bash_profile.
This makes sure node.js environment issue doesn’t block react-scripts.
Advanced Troubleshooting
If easy steps fail:
- Set NODE_ENV: Make it “development” with export NODE_ENV=development to add test tools.
- Docker Users: Check .dockerignore doesn’t skip node_modules.
- Version Check: Change react-scripts in package.json to new, like “^5.0.1”, then npm install.
- Port Conflicts: If about starting, add PORT=3001 to a .env file.
These cover troubleshooting create-react-app fully.
For safe setups, learn about spotting and reporting phone scams.
Best Practices to Avoid Future Errors
It’s better to stop problems. Try these tips:
- Always Install After Cloning: Do npm install first after git clone.
- Use Consistent Tools: Pick one like npm or Yarn for the project.
- Keep Paths Simple: Use small letters, no spaces in names.
- Version Control Dependencies: Save package.json but not node_modules.
- Browser-Based Alternatives: For fast checks, use sites like CodeSandbox without local setup.
Words from coders: “Npm install fixed it right away after long tries,” says a Stack Overflow user.
Example: In a group project, if one uses Yarn and another npm, issues come. Use the same to skip react project won’t start.
For setup facts, see 192.168.31.228:8080 how to access your router.
Tools and Resources for React Developers
To get better, beyond fixes:
- Start new projects with create-react-app: npx create-react-app my-app.
- Check Node: node -v should be new, like 18.x.
- Get Help: Ask on Stack Overflow with your computer type and error notes.
Mix with other JS tools for good work, skipping JavaScript build tools error.
Frequently Asked Questions (FAQs)
What does sh: react-scripts: command not found mean?
This error means your computer can’t find a key React tool called react-scripts.It often happens because files are missing after you copy a project.
How can I fix sh: react-scripts: command not found quickly?
Start by running npm install in your project folder to add missing files.If that fails, try adding react-scripts directly with npm install react-scripts –save.
Why do I get sh: react-scripts: command not found after cloning from GitHub?
Cloning skips the node_modules folder where react-scripts lives.You need to run npm install to get those files back.
Can switching from npm to Yarn cause sh: react-scripts: command not found?
Yes, changing tools can mess up lock files and cause mismatches.Pick one tool and delete old lock files to fix it.
Conclusion: Get Your React App Running Smoothly
To wrap up, the sh: react-scripts: command not found error comes from missing files3, bad paths, or tool mixes. Run npm install, check paths, and use one tool to fix it fast. These easy steps from good sources help new React users beat react app failing to compile problems.
What React error did you see last, and how did you solve it? Tell us in the comments to aid others!
References
- Codedamn: How to Fix React-Scripts: Command Not Found Error – Offers permanent reinitialization steps, great for beginners avoiding recurring issues. ↩︎
- Medium: Troubleshooting the ‘react-scripts’ Command Not Recognized Error – Focuses on environmental variables and local installs, helpful for cross-OS users. ↩︎
- Stack Overflow: sh: react-scripts: command not found after running npm start – A Q&A thread with over 700 upvotes on installing dependencies after cloning, ideal for juniors learning npm basics. ↩︎
