Fixing "sh: react-scripts: command not found" Error When Running npm start

The "sh: react-scripts: command not found" error means the react-scripts binary is missing from your shell's PATH, typically because development dependencies weren't installed or the command is being executed from the wrong directory.

When working with the facebook/react repository—particularly within its fixture directories like owner-stacks or view-transition—this error appears immediately upon running npm start if the local react-scripts package isn't properly linked in node_modules/.bin. The React repository uses these fixtures to demonstrate various React features, and they rely on Create React App's build tooling to function.

Root Causes of the react-scripts Command Not Found Error

The error surfaces when your shell cannot locate the react-scripts executable in the current environment's PATH. Based on the fixture configurations in the React source code, five primary scenarios trigger this failure.

Missing devDependencies Installation

In the React repository's fixtures, react-scripts is consistently listed as a devDependency rather than a production dependency. For example, in fixtures/owner-stacks/package.json, the start script invokes react-scripts start but the package itself exists only under devDependencies.

If you run npm install --production or set NODE_ENV=production before installing, npm deliberately skips devDependencies. Consequently, node_modules/.bin/react-scripts never gets created, causing the shell to return "command not found" when the npm script executes.

The react-scripts command works through a symbolic link in node_modules/.bin/ that points to the actual executable within node_modules/react-scripts/bin/. If you manually delete node_modules without reinstalling, or if your file system corrupts these symlinks (common in Windows environments or after interrupted installs), the binary reference breaks even if the package files exist.

Running npm start from the Wrong Directory

The npm start command searches for package.json in the current working directory. In the React repository, fixture folders like fixtures/view-transition/ contain their own package.json files with distinct react-scripts scripts. If you execute npm start from the repository root or a parent directory, npm cannot resolve the local binary path because it looks for node_modules/.bin/ relative to the current location, not the fixture subdirectory.

Global Installation Shadowing

Installing react-scripts globally with npm install -g react-scripts can create PATH conflicts. If a global installation exists but is corrupted or outdated, your shell might resolve the global path first, fail to find the executable there, and never fall back to the local node_modules/.bin/ version. This masking behavior prevents the local fixture's specific react-scripts version from executing.

CI Environment PATH Limitations

Some continuous integration environments spawn non-login shells that don't automatically include ./node_modules/.bin/ in the PATH. In these environments, even after a successful npm install, the bare command react-scripts remains invisible to the shell because the npm binary path isn't exported to the subshell executing the script.

Step-by-Step Solutions to Resolve the Error

Verify and restore the react-scripts binary using these methods, ordered from most common to environment-specific workarounds.

Verify and Install Dependencies

First, ensure all dependencies including devDependencies are present:


# Install all dependencies (including devDependencies)

npm install

# Verify the binary exists

ls node_modules/.bin/react-scripts

# Expected output: react-scripts (or react-scripts.cmd on Windows)

If you must use npm ci in a production-like environment, explicitly include development dependencies:

npm ci --include=dev

Clean and Reinstall node_modules

When symlinks are corrupted or packages are partially installed, purge and rebuild:

rm -rf node_modules package-lock.json
npm install

This forces npm to recreate the node_modules/.bin/ symlinks, including the critical react-scripts link.

Execute from the Correct Directory

Before running npm start, confirm you're in the directory containing the target package.json. For the React repository's Owner-Stacks fixture:

cd fixtures/owner-stacks
npm start

The fixtures/owner-stacks/package.json defines the start script as "start": "react-scripts start", which only resolves correctly when executed from that specific directory where node_modules/.bin/ exists.

Use npx or Direct Binary Paths

When PATH issues persist in CI environments or monorepo structures, bypass the PATH resolution entirely:


# Use npx to resolve the local binary

npx react-scripts start

# Or call the binary directly

./node_modules/.bin/react-scripts start

The npx approach is particularly reliable in the fixtures/view-transition/ directory, where the script definition is "dev:client": "BROWSER=none PORT=3001 react-scripts start". If you encounter the error here, prefixing with npx ensures the binary resolves regardless of shell configuration.

Real-World Examples in the React Repository

The facebook/react repository contains multiple fixtures that demonstrate this error scenario when dependencies are missing:

  • fixtures/owner-stacks/package.json: Defines "start": "react-scripts start" at line 13. Running npm start here without first installing dependencies produces the exact "command not found" error.
  • fixtures/view-transition/package.json: Uses react-scripts in the dev:client script (line 30), demonstrating that custom script names still rely on the same binary resolution.
  • fixtures/nesting/package.json: References an older react-scripts version (3.4.1) in its dev-app script, showing the error isn't version-specific.
  • fixtures/ssr/package.json: Includes legacy react-scripts 0.9.5, confirming that even historical versions trigger this error when binaries are absent.

In all these cases, the error manifests identically: the shell reports sh: react-scripts: command not found because the fixture's local node_modules/.bin/ directory either doesn't exist or isn't on the PATH.

Summary

  • The error indicates react-scripts is missing from node_modules/.bin/, usually due to skipped devDependencies or corrupted installs.
  • Always run npm install without production flags when working with React fixtures to ensure react-scripts and its binary symlinks are created.
  • Execute commands from the directory containing the relevant package.json, such as fixtures/owner-stacks/ for that specific fixture.
  • Use npx react-scripts start as a fallback when CI environments or shell configurations block automatic PATH resolution.
  • Avoid global installations of react-scripts to prevent version conflicts and PATH shadowing issues.

Frequently Asked Questions

Why does npm start say react-scripts not found?

This occurs when the react-scripts binary isn't present in node_modules/.bin/, typically because you ran npm install --production (which skips devDependencies) or you're executing the command from a directory that doesn't contain the package.json defining the start script. In the React repository, this commonly happens when developers clone the repo and immediately try npm start inside fixture folders like fixtures/owner-stacks/ without first installing dependencies.

How do I fix react-scripts not found in a CI/CD pipeline?

Add --include=dev to your npm ci command to ensure devDependencies like react-scripts are installed, or modify your pipeline to use npx react-scripts start instead of npm start. If your CI environment uses a minimal shell that doesn't inherit the npm PATH, explicitly call ./node_modules/.bin/react-scripts start to bypass PATH resolution issues entirely.

Should I install react-scripts globally?

No. Installing react-scripts globally with npm install -g react-scripts can cause version conflicts and PATH shadowing that mask local installations. The React repository fixtures and Create React App projects are designed to use locally installed versions specified in package.json. Global installations often lead to "command not found" errors if the global version is removed or corrupted while the shell still looks for it first.

What if npx react-scripts start still fails?

If npx cannot locate the binary, your node_modules directory is likely missing or severely corrupted. Run rm -rf node_modules package-lock.json && npm install to force a fresh installation. On Windows, ensure your antivirus software isn't quarantining the react-scripts.cmd file, and check that your Node.js installation has proper permissions to create symlinks in node_modules/.bin/.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →