Last updated: Apr 4, 2024
Reading timeยท3 min

To solve the error "react-scripts is not recognized as an internal or external
command, operable program or batch file", open your terminal in your project's
root directory and install the react-scripts package by running
npm install react-scripts and clear your npm cache if necessary.
Open your terminal in your project's root directory (where your package.json
file is located) and run the following command:
# ๐๏ธ With npm npm install react-scripts # ---------------------------------------------- # ๐๏ธ With yarn yarn add react-scripts

If the error is not resolved, try to delete your node_modules and
package-lock.json (not
package.json) files, re-run npm install and restart your IDE.
If you are on Windows, run the following commands in CMD.
# ๐๏ธ (Windows) delete node_modules and package-lock.json rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐๏ธ clean the npm cache npm cache clean --force # ๐๏ธ install packages npm install
If you are on macOS or Linux, run the following commands in bash or zsh.
# ๐๏ธ (macOS/Linux) delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐๏ธ clean the npm cache npm cache clean --force # ๐๏ธ install packages npm install
Make sure to restart your IDE and dev server if the error persists.
VSCode often glitches and a reboot solves the issue sometimes.
npm audit fix commandIf the error persists, open your terminal in your project's root directory and run the npm audit fix command:
npm audit fix

The npm audit fix command looks for vulnerabilities and applies remediations
to the package tree.
If you get an error while running the command, add the --force flag at the
end:
npm audit fix --force

You can also try running the command with the --legacy-peer-deps option.
npm audit fix --legacy-peer-deps
react-scriptsIf the error is not resolved, try installing the latest version of
react-scripts.
# ๐๏ธ With npm npm install react-scripts@latest # ---------------------------------------------- # ๐๏ธ With yarn yarn add react-scripts@latest

Another thing you can try is to clean the npm cache and run the npm rebuild
command.
npm cache clean --force npm rebuild npm install
The npm rebuild command is similar to npm install and is most often used
after upgrading your Node.js version.
react-scripts is in your dependencies objectIf the error persists, open your package.json file and make sure it contains
the react-scripts package in the dependencies object.
{ // ... rest "dependencies": { "react-scripts": "^5.0.0" } }
The react-scripts module should NOT be globally installed or be in your
project's devDependencies, it should be in the dependencies object in your
package.json file.
You can try to manually add the line and re-run npm install.
npm install
Or install the latest version of the package:
npm install react-scripts@latest
If the error persists, you likely haven't set up Node.js in your system's PATH environment variable on Windows.
I've written a detailed guide on how to set up Node.js correctly on Windows.
Click on the link and follow the step-by-step instructions.
After setting up Node.js in your PATH, restart your terminal and issue the
react-scripts installation command.
npm install react-scripts@latest
You can learn more about the related topics by checking out the following tutorials: