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

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
2 min

banner

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

To solve the error "nuxt 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 nuxt package by running npm install nuxt 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 nuxt # ---------------------------------------------- # ๐Ÿ‘‡๏ธ Or with yarn yarn add nuxt

install nuxt using npm

Make sure your package.json file looks something like the following.

package.json
{ "scripts": { "dev": "nuxt", "build": "nuxt build", "generate": "nuxt generate", "start": "nuxt start" } }

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

# Delete your node_modules and reinstall your dependencies

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 macOS or Linux, issue the following commands in bash or zsh.

shell
# for macOS and Linux rm -rf node_modules rm -f package-lock.json rm -f yarn.lock # ๐Ÿ‘‡๏ธ clean npm cache npm cache clean --force # ๐Ÿ‘‡๏ธ install packages npm install

If you are on Windows, issue the following commands in CMD.

cmd
# for Windows rd /s /q "node_modules" del package-lock.json del -f yarn.lock # ๐Ÿ‘‡๏ธ clean 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 things sometimes.

# Creating a nuxt project

If you are trying to create a new nuxt project, you can use the following command:

shell
npx create-nuxt-app my-project

After the project is created, open your terminal in the project's directory, run the npm run dev command and the application will run on http://localhost:3000.

The npx prefix will look for the create-nuxt-app package in your local dependencies and if it isn't found, it will install the package before running the command.

# Verify nuxt is installed

If the error persists, open your package.json file and make sure it contains the nuxt package in the dependencies object.

package.json
{ // ... rest "dependencies": { "nuxt": "^2.15.8" } }

The nuxt 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

issue npm install command

Or install the latest version of the package:

shell
npm install nuxt@latest

install latest version of nuxt

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

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.

Copyright ยฉ 2024 Borislav Hadzhiev