How to fix Cannot find module "react-scripts" in React

ReactBEGINNERMEDIUMUpdated Dec 9, 2025ยท 124 views

This error occurs when the react-scripts package is missing from your node_modules directory. It typically happens after cloning a Create React App project or when dependencies fail to install properly.

Quick fix

Fixes MODULE_NOT_FOUND

{
  "dependencies": {
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-scripts": "5.0.1"
  }
}
  1. Verify package.json contains react-scripts
  2. Install dependencies
  3. Check for path issues
  4. Delete and reinstall if installation fails
react โ€” error
{
"dependencies": {
"react": "^18.0.0",
"react-dom": "^18.0.0",
"react-scripts": "5.0.1"
}
}
Cannot find module "react-scripts"

What this error means

The "Cannot find module 'react-scripts'" error indicates that Node.js cannot locate the react-scripts package in your project's node_modules directory. The react-scripts package is a core dependency of Create React App that contains all the configuration and scripts needed to run, build, and test your React application. This error most commonly occurs when you clone a Create React App repository and try to run npm start without first installing dependencies, or when the installation process fails or is interrupted. It can also happen if your node_modules directory becomes corrupted or if there are issues with your package manager's cache. Unlike some module errors that can be resolved with global installations, react-scripts should always be installed locally as a project dependency, not globally.

Typical symptoms

  • Running npm start fails immediately with "Cannot find module 'react-scripts'"
  • Build command (npm run build) throws module not found error
  • Test command (npm test) fails to execute
  • The node_modules/react-scripts directory is missing or empty
  • Commands that worked previously now fail after moving or cloning the project

Common causes

  1. Dependencies were never installed after cloning or downloading the project
  2. The node_modules directory was deleted or corrupted
  3. npm install or yarn install command failed or was interrupted
  4. Project path contains special characters (spaces, hash symbols) that break module resolution
  5. package.json is missing react-scripts in the dependencies section
  6. Package manager cache corruption preventing proper installation
  7. Conflicting Node.js or npm versions causing installation issues

How to fix "Cannot find module "react-scripts""

1Verify package.json contains react-scripts

Open your package.json file and confirm that react-scripts is listed in the dependencies:

json
{
  "dependencies": {
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-scripts": "5.0.1"
  }
}

If react-scripts is missing from dependencies, add it manually or reinitialize the project with Create React App.

Important: react-scripts should be in dependencies, NOT devDependencies.

2Install dependencies

Run the installation command for your package manager:

bash
# Using npm
npm install

# Using yarn
yarn install

# Using pnpm
pnpm install

Wait for the installation to complete and verify that node_modules/react-scripts directory is created.

3Check for path issues

Ensure your project path doesn't contain special characters that can break module resolution:

Bad paths:
- C:\Users\My Documents\my react app (contains spaces)
- /home/user/app#3 (contains hash symbol)
- D:\Projects\app(2) (contains parentheses)

Good paths:
- C:\Users\Documents\my-react-app
- /home/user/projects/app-3
- D:\Projects\app-2

If your path contains special characters, move the project to a path with only alphanumeric characters and hyphens.

4Delete and reinstall if installation fails

If the standard installation doesn't work, perform a clean reinstall:

bash
# Remove node_modules and lock files
rm -rf node_modules
rm package-lock.json  # or yarn.lock or pnpm-lock.yaml

# Clear npm cache
npm cache clean --force

# Reinstall dependencies
npm install

For Windows users, use these commands instead:

cmd
rmdir /s /q node_modules
del package-lock.json
npm cache clean --force
npm install
5Install react-scripts directly if still missing

If react-scripts is still not installed after the previous steps, install it explicitly:

bash
npm install react-scripts

# Or with a specific version
npm install react-scripts@latest

After installation completes, verify the installation:

bash
npm list react-scripts

You should see output showing the installed version of react-scripts.

6Verify Node.js and npm versions

Ensure you're using compatible versions of Node.js and npm:

bash
node --version
npm --version

Create React App requires:
- Node.js 14.0.0 or later
- npm 6.14.0 or later

If your versions are outdated, update Node.js from https://nodejs.org/ or use a version manager like nvm:

bash
# Update to latest LTS version with nvm
nvm install --lts
nvm use --lts

Advanced notes

Why react-scripts Should Not Be Global: Unlike some CLI tools, react-scripts should never be installed globally (npm install -g react-scripts). Each Create React App project may use different versions of react-scripts with different configurations. Global installations can cause version conflicts and unexpected behavior.

Package Manager Compatibility: If you're working on a team project, ensure everyone uses the same package manager. Mixing npm, yarn, and pnpm can cause lock file conflicts and installation issues. Check which lock file exists in the repository (package-lock.json for npm, yarn.lock for yarn, pnpm-lock.yaml for pnpm) and use the corresponding package manager.

CI/CD Environments: In continuous integration pipelines, this error often occurs when the CI cache is corrupted or when the build environment doesn't have proper network access to npm registries. Consider adding npm ci instead of npm install for more reliable builds, and verify that your CI environment can access the npm registry.

Monorepo Considerations: In monorepo setups using tools like Lerna or Nx, module resolution can be more complex. Ensure that hoisting is configured correctly and that react-scripts is installed in the correct package location.

Alternative: Migrate to Vite: If you're starting a new project or experiencing persistent issues with Create React App, consider migrating to Vite, which offers faster build times and simpler configuration. Create React App is no longer actively maintained as of 2023, and many teams are transitioning to modern alternatives.

Frequently asked questions

What does "MODULE_NOT_FOUND" mean?
js cannot locate the react-scripts package in your project's node_modules directory. The react-scripts package is a core dependency of Create React App that contains all the configuration and scripts needed to run, build, and test your React application. This error most commonly occurs when you clone a Create React App repository and try to run npm start without first installing dependencies, or when the installation process fails or is interrupted.
How do I fix "MODULE_NOT_FOUND"?
This error occurs when the react-scripts package is missing from your node_modules directory. It typically happens after cloning a Create React App project or when dependencies fail to install properly.
What causes "MODULE_NOT_FOUND"?
Dependencies were never installed after cloning or downloading the project The node_modules directory was deleted or corrupted npm install or yarn install command failed or was interrupted
Is the "MODULE_NOT_FOUND" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading