Have you ever run into the error that “‘react-scripts’ is not recognized as an internal or external command”? So in this post, we will show you the possible causes and sum up several simple methods to help you tackle with this problem.
The reason for the “‘react-scripts’ is not recognized as an internal or external command” error
When you run the program with the command npm start or npm test with React project, the error ‘react-scripts’ is not recognized as an internal or external command that appears on the console. The output will look like the image below.
This error can happen when your program misses the react-scripts package in node_modules during project installation. You can follow the next part of the article to get your solutions.
Create-react-app makes use of the NPM package react-scripts. It’s a “black box” with the essentials inside:
- Dependencies: Webpack, ESLint, and Babel.
- Configuration: Webpack, Babel, and ESLint configuration files for both development and production environments.
- Scripts: Run react-scripts start, for instance, will start the Webpack server in the development environment and execute commands for this package.
This package will be installed into the application immediately once we install it, but it may be lost if you apply it wrong or delete it during development. You may reinstall it with the following command.
npm install react-scripts --save
After you installed, the package react-scripts can be recognized as an internal or external command, so the error will also be prevented. Therefore, We can run the project generally without any problems.
Removing node_modules before running the program
rm -rf node_modules && npm install
This will fix the missing react-scripts in the article, and any minor errors in the project or missing packages will also be fixed. Wish you success with the methods mentioned in the article.
In summary, the article has shown you why
'react-scripts' is not recognized as an internal or external command error occurs and how you can solve it. However, I recommend removing node_modules before running the program because it will fix missing packages efficiently and comprehensively.
Maybe you are interested:
- sh: react-scripts: command not found
- JSX element type does not have any construct or call signatures
Name of the university: PTIT