Last updated: Apr 4, 2024
Reading timeยท2 min
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:
# ๐๏ธ With npm npm install nuxt # ---------------------------------------------- # ๐๏ธ Or with yarn yarn add nuxt
Make sure your package.json
file looks something like the following.
{ "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
.
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
.
# 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.
# 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
nuxt
projectIf you are trying to create a new nuxt
project, you can use the following
command:
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.
nuxt
is installedIf the error persists, open your package.json
file and make sure it contains
the nuxt
package in the dependencies
object.
{ // ... 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
.
npm install
Or install the latest version of the package:
npm install nuxt@latest
You can learn more about the related topics by checking out the following tutorials: