33

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! andromeda@1.0.0 dev: `nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the andromeda@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Marquezz
  • 1,253
  • 1
  • 7
  • 9

9 Answers9

82

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.

Soviut
  • 88,194
  • 49
  • 192
  • 260
Marquezz
  • 1,253
  • 1
  • 7
  • 9
16

Make sure nuxt is installed in your Nuxt project:

$ cd /path/to/nuxt-project
$ npm list nuxt
nuxt-project@1.0.0 /path/to/nuxt-project
└── nuxt@2.6.3 

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"
},
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
  • It still has the same error. My dependencies: "dependencies": { "nuxt": "^2.4.0", "cross-env": "^5.2.0", "bootstrap-vue": "^2.0.0-rc.11", "bootstrap": "^4.1.3", "@nuxtjs/axios": "^5.3.6" }, – Marquezz May 07 '19 at 02:41
  • @Marquezz Just to be sure, you are running `npm install` and `npm run dev` under the project directory? What do you get when you do `npm list nuxt`? – Gino Mempin May 07 '19 at 03:20
  • I am sure that i'm on the right directory.and when i run npm list nuxt i get this: `-- nuxt@2.6.1 I search on google and i found some people having problems with nuxt + windows 10 – Marquezz May 08 '19 at 02:04
  • 1
    @Marquezz Oh OK. I updated my answer. Try to change the `dev` command to use the explicit node_modules path for `nuxt`. – Gino Mempin May 08 '19 at 02:21
  • I followed these steps and this error went away for me. But, I had to use `yarn install` after this to link the dependencies properly and do `npm run dev` – retr0 Jul 22 '19 at 14:24
9

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

Yamen Ashraf
  • 2,637
  • 2
  • 20
  • 26
3

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"
  },
Vergo
  • 49
  • 2
  • 4
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 )

0

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.

Daniel Danielecki
  • 8,508
  • 6
  • 68
  • 94
0

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

-3

It simply means nuxt is not installed.

Try running npm install nuxt

Shakil Alam
  • 308
  • 4
  • 9
-4

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.

Petar
  • 1
  • 1