How to solve 'vue-cli-service' is not recognized as an internal or external command?

vue.jsVue Cli-3

vue.js Problem Overview


I am getting an error when trying to run npm run serve. At first I installed node.js then vue as well as vue/cli. But when I am trying to run server as -> npm run serve at that time I'm getting error like 'vue-cli-service' is not recognized as an internal or external command.

I used below codes for installation:

npm install -g vue
npm install -g @vue/cli
enter image description here

can someone guide me what to do to solve this issue ?

vue.js Solutions


Solution 1 - vue.js

I think you are using cmd in windows.

Try deleting the node_modules folder and after that run npm i from the cmd.

Then try running npm run serve again and see if it works this time

Solution 2 - vue.js

Install vue/cli-service globally

npm install @vue/cli-service -g

This will install global npm package.

@vue/cli-service is usully installed as global, because you do not usually copy these types of packages to every project.

If the global npm package gets corrupted, it is not stored in node_modules folder, but rather in other depending on the os. Therefore removing node_modules does not help. Locations for global node_modules folders are

  • %USERPROFILE%\AppData\Roaming\npm\node_modules (Win10) or
  • /usr/local/lib/node_modules (Linux),

check this stack overflow post on how to locate global packages.

Solution 3 - vue.js

it will depend on the package manager you are using

  1. delete node_modules

  2. if you are using yarn run yarn or yarn install and then yarn serve

  3. if you are using npm run npm install and then npm run serve

Solution 4 - vue.js

In my case, the package @vue/cli-service is installed in my local node_modules environment, but not my global environment, so it cannot be used as a command. I type .\node_modules\.bin\vue-cli-service serve and it works.

Solution 5 - vue.js

As it is mentioned in terminal that node_modules is missing from your project, so you can't directly use npm run serve, first you have to do npm install then do npm run serve. It will work fine

Solution 6 - vue.js

In my case I ran below commands in GitBash and it worked fine

  1. npm install
  2. npm run serve

Solution 7 - vue.js

  1. If you are using cmd in windows.
  2. deleting the node_modules folder and after that run npm istall from the cmd.
  3. run npm run serve and see if it works this time

Solution 8 - vue.js

In my case, I have checked the folder of node_modules was missing. I am using Windows. So I run this in cmd.

  1. npm install
  2. npm run serve

Then I check it in localhost like usual.

Solution 9 - vue.js

This issue mostly happens when either @vue/cli is not installed or in most cases, > @vue/cli is already installed and you are currently working on a project and when running

  • yarn serve or npm run serve.

Most at times, this issue is been caused by broken dependencies. to fix this issue, simple run

  • yarn install or npm install

depending on your package manager.

Solution 10 - vue.js

well after trying all the solutions above and it still haven't worked for you then you probably have a stupid space in the full directory of your Vue project like in my case. so remove that that space and it will work from then on.

Solution 11 - vue.js

Remember to set the NODE_ENV=development and run npm install again

Solution 12 - vue.js

Try changing the project path to one without spaces, it worked on windows 10

Solution 13 - vue.js

I had faced the same problem in windows. Then first I deleted the node_module. then I run npm install.

Solution 14 - vue.js

For Windows you should modify package.json to:

  "scripts": {
    "serve": "vue-cli-service.cmd serve",
    "build": "vue-cli-service.cmd build",
    "lint": "vue-cli-service.cmd lint"
  }

,

Solution 15 - vue.js

I had the same issue using windows + WSL2 (Ubuntu 20.04). Looking at the logs generated after trying to run npm i I noticed that my WSL2 environment did not have python2 installed. So to solve I ran the following commands:

  1. sudo apt-get install python2
  2. rm -rf node_modules
  3. npm i
  4. npm run serve

Solution 16 - vue.js

I faced the same in Windows. Had to run npm install again. Then it worked perfectly.

Solution 17 - vue.js

Wait, what's the difference between @vue/cli and @vue/cli-service? When you install both, they show different number of packages installed. The latter solved my issue actually but everyone keeps saying install @vue/cli.

Solution 18 - vue.js

In my case it was enough to uninstall package-lock.json and then npm i

Solution 19 - vue.js

I have a project, I can run it well on Linux, but i have the same issue on windows, I solve it this way (I hope in your case it works too):

  1. Delete the node_modules

  2. Install it again with npm i

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDcoder14View Question on Stackoverflow
Solution 1 - vue.jss4k1bView Answer on Stackoverflow
Solution 2 - vue.jsScholtzView Answer on Stackoverflow
Solution 3 - vue.jsNtwari Clarance LiberisteView Answer on Stackoverflow
Solution 4 - vue.jsLucien ZhangView Answer on Stackoverflow
Solution 5 - vue.jsShubham SharmaView Answer on Stackoverflow
Solution 6 - vue.jsKiran ModiniView Answer on Stackoverflow
Solution 7 - vue.jsAli RazaView Answer on Stackoverflow
Solution 8 - vue.jsahartamiView Answer on Stackoverflow
Solution 9 - vue.jsRomanric AkamView Answer on Stackoverflow
Solution 10 - vue.jsMuhammad KashifView Answer on Stackoverflow
Solution 11 - vue.jsWilliam KellerView Answer on Stackoverflow
Solution 12 - vue.jsMaher FakhourView Answer on Stackoverflow
Solution 13 - vue.jsHasibul-View Answer on Stackoverflow
Solution 14 - vue.jsAndrey -hidden-View Answer on Stackoverflow
Solution 15 - vue.jsSales LopesView Answer on Stackoverflow
Solution 16 - vue.jsburke_View Answer on Stackoverflow
Solution 17 - vue.jsJustin FarrugiaView Answer on Stackoverflow
Solution 18 - vue.jsStanisław SztrajtView Answer on Stackoverflow
Solution 19 - vue.jsIsmael GomezView Answer on Stackoverflow