'craco' is not recognized as an internal or external command

avatar

Borislav Hadzhiev

Last updated: Mar 1, 2022

banner

Photo from Unsplash

'craco' is not recognized as an internal or external command #

To solve the error "craco 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 craco package by running npm install @craco/craco 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 @craco/craco # ---------------------------------------------- # 👇️ With yarn yarn add @craco/craco

If you get an error when installing @craco/craco, add the --force flag at the end of the command:

shell
npm install @craco/craco --force

Make sure the scripts object in your package.json file looks something like:

package.json
{ "scripts": { "start": "craco start", "build": "craco build", "test": "craco test" } }

Now you can run craco commands by accessing the scripts in your package.json file, e.g. npm run start.

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 persists. VSCode often glitches and a reboot solves things sometimes.

If you are trying to configure craco in your craco.config.js file, refer to the configuration section of the craco npm page.

If the "craco is not recognized as an internal or external command" error persists, open your package.json file and make sure it contains the @craco/craco package in thedependencies object.

package.json
{ // ... rest "dependencies": { "@craco/craco": "^6.4.3", } }

The @craco/craco 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 lines and re-run npm install.

shell
npm install

Or install the latest version of the package:

shell
npm install @craco/craco@latest

Conclusion #

To solve the error "craco 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 craco package by running npm install @craco/craco and clear your npm cache if necessary.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.