Borislav Hadzhiev
Thu Mar 03 2022·2 min read
Photo by Allef Vinicius
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.
# 👇️ delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json # 👇️ clean npm cache npm cache clean --force npm install
If 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
If 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
If the "react-scripts is not recognized as an internal or external command"
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