DEV Community

Kyle Y. Parsotan
Kyle Y. Parsotan

Posted on

🚨 Fix “sh: react-scripts: command not found” (Complete Guide)

If you’re working on a React project and suddenly see:

sh: react-scripts: command not found
Enter fullscreen mode Exit fullscreen mode

Don’t panic — this is a very common issue, especially in projects created with Create React App.

This guide breaks down:

  • ✅ Why this happens
  • 🧨 Common mistakes
  • ⚡ Proven fixes
  • 🚀 Long-term solutions

🧠 Why this error happens

This error means your system can’t find the react-scripts binary.

react-scripts is the tool that powers:

  • npm start
  • npm build
  • npm test

If it’s missing or broken → your app won’t run.


🧨 Common causes

Here’s what usually triggers the issue:

  • node_modules folder is missing or corrupted
  • react-scripts not installed in dependencies
  • ❌ Wrong working directory
  • ❌ Mixing package managers (npm, yarn, pnpm)
  • ❌ Broken install or cache
  • ❌ Node version incompatibility

⚡ Fix #1: Reinstall dependencies (Most Effective)

Start with a clean slate:

rm -rf node_modules package-lock.json
npm install
npm start
Enter fullscreen mode Exit fullscreen mode

👉 This alone fixes most cases.


📦 Fix #2: Install react-scripts manually

Check your package.json:


"dependencies": {
  "react-scripts": "5.0.1"
}
Enter fullscreen mode Exit fullscreen mode

If it’s missing:

npm install react-scripts
Enter fullscreen mode Exit fullscreen mode

📁 Fix #3: Make sure you're in the right folder

Run:

ls
Enter fullscreen mode Exit fullscreen mode

You should see:

  • package.json
  • src/
  • public/

If not → navigate to your project:

cd your-project-name
Enter fullscreen mode Exit fullscreen mode

🧪 Fix #4: Run with npx

Quick workaround:

npx react-scripts start
Enter fullscreen mode Exit fullscreen mode

👉 This bypasses local binary issues.


⚙️ Fix #5: Run the binary directly

On Mac/Linux:

./node_modules/.bin/react-scripts start
Enter fullscreen mode Exit fullscreen mode

If this works → your PATH is misconfigured.


🔥 Fix #6: Clear npm cache (if installs fail)

npm cache clean --force
npm install
Enter fullscreen mode Exit fullscreen mode

🧠 Fix #7: Check Node version

Some versions break compatibility.

node -v
Enter fullscreen mode Exit fullscreen mode

Recommended:

  • Node 18, 20, 22, 25

Use a version manager if needed.


⚠️ Fix #8: Don’t mix package managers

If you see:

  • package-lock.json → use npm
  • yarn.lock → use yarn

🚫 Don’t mix them — it causes dependency conflicts.


🚀 The bigger issue (and better solution)

Let’s be real:
Projects using Create React App and react-scripts are aging.

Modern alternatives are faster and more reliable:

  • ⚡ Vite
  • 🔥 Next.js

🆕 Bonus: Create a new app with Vite

If you’re starting fresh:

npm create vite@latest my-app
cd my-app
npm install
npm run dev
Enter fullscreen mode Exit fullscreen mode

👉 Much faster startup, fewer issues.


🧠 Final thoughts

This error isn’t really about React — it’s about your environment setup.

Once you understand that:

You stop guessing… and start fixing things fast.


💬 Have you hit this bug?

Drop your setup (Node version, package manager, error logs), and I’ll help debug it with you 👇

Top comments (0)