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

23

122

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 ?

Noise answered 27/10, 2019 at 13:27 Comment(3)
Try running npm install before npm run serve.Clemence
npm install -g @vue/cli-serviceTuyere
@DanieleTesta: This was the only thing that worked for me. Maybe post as an answer?Festination
Z
196

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

Zarf answered 27/10, 2019 at 14:44 Comment(7)
@Sakib without deleting node_modules, it worked for me. ThanksNoise
Done all step and when cmd using npm run serve then get error 'vue-cli-service' is not recognized as an internal or external command, operable program or batch file.Corbeil
'vue-cli-service' 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] serve: vue-cli-service serve npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] serve script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\CC\AppData\Roaming\npm-cache_logs\2020-03-27T16_32_39_297Z-debug.logCorbeil
Try to install vue-cli-service run npm install -g @vue/cli then run npm run serveZarf
Worked for me too, in my case when I incorrectly switched between two branches (git) and left some changes, that problem occurred.Caa
worked for me because i did npm needed to reinstall because it was installed on another platform.Adrenal
this was perfect for my issue, switching between a non vue and back to a vue branch.Catercousin
E
61

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.

Enisle answered 26/5, 2020 at 15:14 Comment(2)
For me, personally, this is the only answer that helpedParsee
Same here.. together with #53713393Dav
N
17

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

Negotiate answered 29/8, 2020 at 13:40 Comment(0)
H
4

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.

Hanhana answered 9/4, 2020 at 3:52 Comment(0)
N
3

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

Nolie answered 18/4, 2020 at 12:45 Comment(1)
This solved a similar problem I was having with building an ESP32 project, restful_server. npm install, then npm run build and the project would compile after the dist folder showed up.Windpollinated
B
2

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

  1. npm install
  2. npm run serve
Bristletail answered 30/10, 2020 at 19:18 Comment(0)
S
2
  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
Statist answered 17/12, 2020 at 16:25 Comment(0)
B
2

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.

Burnley answered 19/6, 2021 at 21:31 Comment(0)
M
1

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.

Marrilee answered 13/8, 2021 at 3:10 Comment(0)
P
1

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.

Panfish answered 28/8, 2021 at 20:51 Comment(0)
W
1

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

Weigh answered 18/9, 2021 at 4:57 Comment(0)
K
1

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

Kuhns answered 12/11, 2021 at 16:15 Comment(0)
C
0

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

Cutaneous answered 3/11, 2020 at 4:1 Comment(0)
L
0

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"
  }

,

Lac answered 22/3, 2021 at 20:30 Comment(0)
E
0

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
Eelgrass answered 3/5, 2021 at 10:38 Comment(0)
F
0

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

Fiora answered 28/5, 2021 at 9:56 Comment(0)
U
0

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.

Upraise answered 19/8, 2021 at 20:4 Comment(0)
P
0

try running npm i or npm install and then proceed to run npm i vue after previous installation done. works for me

Pacific answered 18/6, 2022 at 6:3 Comment(0)
V
0

you need use "npm install" at Command Line

Victorinavictorine answered 27/8, 2022 at 16:39 Comment(0)
A
0

Before running "npm install", try running this command first:

npm set strict-ssl false
Ava answered 4/11, 2022 at 14:35 Comment(0)
A
0

Like you, I got the error below when I ran npm run serve from the CMD command line,

'vue-cli-service' is not recognized as an internal or external command, operable program or batch file.

I got past this familiar error by using the following command to add the npm folder to the PATH that CMD searches for executables:

path=%path%;C:\Users\<USERNAME>\AppData\Roaming\npm

where <USERNAME> is your Windows user profile directory name. Only then was I able to run the following commands successfully:

npm install 
npm run serve
Ava answered 9/12, 2022 at 20:20 Comment(0)
B
0

What solved the issue for me was renaming the directory. I had used the symbol "&" on the folder name and it seems to break things, so changing it to "and" fixed the issue.

This will probably be an incredibly niche thing, but if I help even 1 person it's fine by me.

Blew answered 30/12, 2022 at 22:15 Comment(0)
S
-1

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

Stifling answered 2/11, 2021 at 13:59 Comment(1)
This has already been mentioned in some of the other answers. When answering older questions that already have answers, please make sure you provide either a novel solution or a significantly better explanation than existing answers.Millisent

© 2022 - 2024 — McMap. All rights reserved.