Fix - 'react-scripts' is not recognized as an internal or external command

avatar

Borislav Hadzhiev

Thu Mar 03 20222 min read

Fix - 'react-scripts' is not recognized as an internal or external command #

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:

shell
# 👇️ 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.

shell
# 👇️ 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
Make sure to restart your IDE and dev server if the error still persists. VSCode often glitches and a reboot solves things sometimes.

If the error persists, open your terminal in your project's root directory and run the npm audit fix command:

shell
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:

shell
npm audit fix --force

If the error is not resolved, try installing the latest version of react-scripts.

shell
# 👇️ 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.

package.json
{ // ... 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.

shell
npm install

Or install the latest version of the package:

shell
npm install react-scripts@latest
Use the search field on my Home Page to filter through my more than 1,000 articles.