sh: react-scripts: Command Not Found — Why It Happens and How to Fix It Fast

Hitting “sh: react-scripts: command not found” when running npm start? This guide covers every cause and fix — from missing node_modules to Docker and CI/CD environments.

Command Not Found


You type npm start, hit Enter, and instead of your React app booting up, you get this:

sh: react-scripts: command not found
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT

The sh: react-scripts: command not found error is one of the most common walls React developers hit, and it happens at the worst moments — right after cloning a repo, switching machines, or setting up a new environment. The frustrating part is that it usually has nothing to do with your actual code. Your components are fine. Your logic is fine. The problem is in the environment.

This post walks through every real cause of this error and the fix for each one.


What react-scripts Actually Is

Before jumping into fixes, it helps to understand what react-scripts does. It’s a package that ships with Create React App. It wires up all the tooling — Webpack, Babel, ESLint, Jest — so you can run commands like npm start, npm test, and npm run build without configuring any of that yourself.

When you run npm start, npm looks at your package.json scripts section:

json
"scripts": {
  "start": "react-scripts start"
}

It then looks for the react-scripts binary inside node_modules/.bin/. If it’s not there, the shell can’t find it, and you get the error. That’s the root cause in almost every case: the react-scripts package is missing, incomplete, or not where npm expects it.


Cause 1: node_modules Is Missing or Incomplete

This is by far the most common reason. It happens when you:

  • Clone a repo from GitHub (node_modules is in .gitignore and never committed)
  • Delete node_modules to free up disk space
  • Pull a project onto a new machine
  • Upgrade Node or npm and the existing node_modules becomes stale

The fix:

bash
npm install

Run this from the root of your project — the same directory that contains package.json. This downloads all dependencies, including react-scripts, into a fresh node_modules folder.

If you’re using Yarn:

bash
yarn install

One important note: don’t mix package managers on the same project. If the project was initialized with Yarn, stick with Yarn. If it was npm, stick with npm. Mixing them can corrupt the lock file and cause partial installs.

After the install completes, run npm start again. This resolves the issue in the majority of cases.


Cause 2: react-scripts Is Not Listed in package.json

Sometimes react-scripts gets removed from package.json dependencies, either by accident or by a bad merge. If you run npm install and the package isn’t listed, it won’t get installed.

Check if it’s there:

bash
npm ls react-scripts

If you see (empty) or an error, it’s missing from your dependencies. Add it back:

bash
npm install react-scripts --save

This installs the package and adds it back to your package.json dependencies. After that, npm start should work.


Cause 3: You’re in the Wrong Directory

This one is easy to overlook. If you’re running npm start from a parent directory that contains your React project, npm won’t find the right package.json or node_modules. It’s especially common in monorepos where the project structure looks like this:

my-project/
  client/          ← React app is here
    package.json
    node_modules/
  server/
    package.json

If you run npm start from my-project/ instead of my-project/client/, you’ll hit the error.

The fix: navigate into the actual React app directory first:

bash
cd client
npm start

Cause 4: Corrupted node_modules or package-lock.json

Sometimes a partial install or a version conflict leaves node_modules in a broken state. react-scripts might technically be listed in package.json but the binary inside node_modules/.bin/ is missing or broken.

The fix is a clean reinstall:

bash
rm -rf node_modules package-lock.json
npm install

On Windows:

bash
rmdir /s /q node_modules
del package-lock.json
npm install

This removes everything and starts fresh. It takes a bit longer, but it resolves issues that a regular npm install won’t fix. Pay attention to any warnings or errors that print during the install — they can point to dependency conflicts worth knowing about.

Managing dependencies cleanly matters more at scale. The same discipline around environment setup and package management applies in professional settings, whether you’re running a React frontend or building enterprise tools. If you’re curious about how software tools are evaluated at the business level, 65 Work Schedule Software Tools For Your Needs covers how modern software categories get analyzed and compared — a useful framing for thinking about dependency management decisions.


Cause 5: Node.js or npm Version Incompatibility

Older versions of Node.js may not be compatible with the version of react-scripts in your project. Create React App has minimum Node version requirements that change over time.

Check your Node version:

bash
node -v
npm -v

If you’re running Node 12 or below with a recent version of react-scripts, you’ll likely hit issues. The current stable LTS version of Node is the safest choice for most React projects.

If you manage multiple Node versions, use nvm (Node Version Manager):

bash
nvm use 18
npm install
npm start

This lets you switch Node versions per project without touching your global Node installation.


Cause 6: The Error in Docker Environments

Docker is a frequent source of this error. A common mistake is having a COPY instruction in the Dockerfile that copies the local node_modules into the container — or conversely, not running npm install inside the container at all.

A Dockerfile that causes this problem often looks like:

dockerfile
FROM node:18
WORKDIR /app
COPY . .
# Missing: RUN npm install
CMD ["npm", "start"]

The fix — always run npm install inside Docker:

dockerfile
FROM node:18
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]

Copying package.json first and running npm install before copying the rest of the source code also takes advantage of Docker’s layer cache. If your code changes but your dependencies don’t, Docker skips the npm install step on rebuilds.

Also make sure your .dockerignore file excludes node_modules:

node_modules

If local node_modules gets copied into the container, it can shadow the packages that should be installed for the container’s OS architecture.


Cause 7: The Error in CI/CD Pipelines

If the error shows up in GitHub Actions, GitLab CI, CircleCI, or similar, the most likely cause is the pipeline not running npm install before npm start or npm run build. Another common issue is overly aggressive dependency caching — the cache restores a stale node_modules that’s missing react-scripts or has the wrong version.

For GitHub Actions, a minimal working config looks like:

yaml
- name: Install dependencies
  run: npm ci

- name: Build
  run: npm run build

Use npm ci instead of npm install in CI environments. It’s faster, more reliable, and ensures the installed packages match package-lock.json exactly. It also fails loudly if the lock file is out of date, which surfaces problems early.

If you’re caching node_modules, make sure the cache key includes your lock file so a change in dependencies busts the cache:

yaml
- uses: actions/cache@v3
  with:
    path: node_modules
    key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}

Good tooling choices in CI/CD are the kind of thing that separates well-run projects from constantly broken ones. If you’re thinking about how to evaluate development tools more broadly, Top 10 Analytics Tools is a solid read on how to assess tools against real-world needs.


What About Installing react-scripts Globally?

You might see suggestions to install react-scripts globally with npm install -g react-scripts. This is generally not recommended.

Global installs can conflict with project-specific versions. If your project uses react-scripts@5 but you have react-scripts@3 installed globally, you’ll get confusing behavior. Keeping react-scripts as a project dependency in node_modules — and running it through npm scripts — is cleaner and more predictable.


A Quick Diagnostic Checklist

When you hit sh: react-scripts: command not found, run through this list in order:

  1. Are you in the right directory (the one with package.json)?
  2. Does node_modules exist? If not, run npm install.
  3. Is react-scripts listed in package.json dependencies?
  4. Run npm ls react-scripts to confirm it’s actually installed.
  5. Try a clean reinstall: delete node_modules and package-lock.json, then npm install.
  6. Check your Node version. Upgrade to current LTS if it’s old.
  7. In Docker: are you running npm install inside the container?
  8. In CI: are you running npm ci before the build step?

Staying up to date with the dev tools ecosystem helps you spot these environment issues faster. Top Mobile Apps for Staying Updated on Tech covers some useful tools for keeping track of what’s changing in the JavaScript and Node ecosystem.


Key Takeaways

The sh: react-scripts: command not found error always means the shell can’t find the react-scripts binary. The fix is almost always one of:

  • Run npm install — the most common fix after cloning or on a new machine
  • Add react-scripts back to package.json if it’s been removed
  • Do a clean reinstall by deleting node_modules and package-lock.json
  • Navigate to the correct project directory before running npm commands
  • Fix your Dockerfile to run npm install inside the container
  • Use npm ci in CI/CD pipelines and cache correctly

None of these require changing your React code. The error lives at the environment level, and so does the fix.