Borislav Hadzhiev
Mon Mar 07 2022·2 min read
Photo by Dương Trần Quốc
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 # ---------------------------------------------- # 👇️ With yarn yarn add nuxt
Make sure your package.json
file looks something like:
{ "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.
# 👇️ 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
If 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's not found, it will install the package before running
the command.
If the "nuxt is not recognized as an internal or external command" 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