Marquezz
Marquezz

Reputation: 1341

Error in running nuxt project: "'nuxt' is not recognized as an internal or external command"

When I tried to run npm run dev in my nuxt project, my console returned this message:

'nuxt' is not recognized as an internal or external command, 
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Upvotes: 35

Views: 104255

Answers (9)

Александр
Александр

Reputation: 1

after installing the project. You need to install packages in package.json

Upvotes: 0

Daniel Danielecki
Daniel Danielecki

Reputation: 10512

Migrating from Nuxt 2 to Nuxt 3?

Change your scripts in package.json to not refer to nuxt-ts anymore, but just to nuxt instead. Example: "dev": "nuxt-ts", -> "dev": "nuxt dev",, "generate": "nuxt-ts generate", -> "generate": "nuxt generate",, etc.

Upvotes: 0

  • Step 1: rm -rf node_modules package-lock.json

  • Step 2: npm cache clean --force

  • Step 3: npm install ( you may need to add --legacy-peer-deps or --force flag, if npm install is not working )

  • To start again, npm start

  • To make build, npm run build (ssr ) or generate ( csr )

Upvotes: 1

Yamen Ashraf
Yamen Ashraf

Reputation: 2950

Sometimes this blows up because you're not exporting node_modules/.bin directory.

Place or append the following line in your .bashrc or .zshrc:

export PATH=node_modules/.bin:$PATH

Upvotes: 10

Shakil Alam
Shakil Alam

Reputation: 447

It simply means nuxt is not installed.

Try running npm install nuxt

Upvotes: -3

Vergo
Vergo

Reputation: 49

Have the same problem recently.

Solution for me was change the path of scripts section in package.json from this:

  "scripts": {
    "dev": "nuxt",
    "build": "nuxt build",
    "start": "nuxt start",
    "generate": "nuxt generate"
  },

to that:

  "scripts": {
    "dev": "node_modules/.bin/nuxt",
    "build": "node_modules/.bin/nuxt build",
    "start": "node_modules/.bin/nuxt start",
     "generate": "node_modules/.bin/nuxt generate"
  },

Upvotes: 3

Petar
Petar

Reputation: 26

Install globally cross-env: npm install -g cross-env

Then just update package.json scripts to start with "cross-env ...."

example:

"scripts": {
    "dev": "cross-env nuxt",
    "build": "cross-env nuxt build",
    "start": "cross-env nuxt start",
    "generate": "cross-env nuxt generate",
    "lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
},

This works on my Windows 10.

Upvotes: -4

Marquezz
Marquezz

Reputation: 1341

I solved this problem.
I was looking in stackoverflow for similar problems and apparently the problem was the npm cache.
I will let a link bellow with the solution and a quick sample of what i did.

Link to the answer: npm ERR! code ELIFECYCLE

Step 1: npm cache clean --force

Step 2: Delete node_modules by $ rm -rf node_modules folder or delete it manually by going into the directory and right-click > delete. Delete package-lock.json file too.

Step 3: npm install

To start again, npm start

Thanks everyone who take time to help, really appreciate.

Upvotes: 88

Gino Mempin
Gino Mempin

Reputation: 29600

Make sure nuxt is installed in your Nuxt project:

$ cd /path/to/nuxt-project
$ npm list nuxt
[email protected] /path/to/nuxt-project
└── [email protected] 

Here /path/to/nuxt-project contains your package.json and node-modules.

If it isn't installed, add nuxt to your project by doing:

$ npm install --save nuxt

Or put it in your project's package.json then do npm install:

  "dependencies": {
    "nuxt": "^2.0.0"
  },

UPDATE:
If you are still getting "nuxt not recognized" problems, try to use explicit path to nuxt from your node_modules directory.

Given this directory (after doing npm install --save nuxt):

nuxt-project
|- node_modules
   |- .bin
      |- nuxt
|- package.json

Update the dev command in package.json with:

"scripts": {
  "dev": "node_modules/.bin/nuxt"
},

Upvotes: 16

Related Questions