How to solve 'vue-cli-service' is not recognized as an internal or external command?
vue.jsVue Cli-3vue.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
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
-
delete node_modules
-
if you are using yarn run
yarn
oryarn install
and thenyarn serve
-
if you are using npm run
npm install
and thennpm 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
npm install
npm run serve
Solution 7 - vue.js
- If you are using cmd in windows.
- deleting the node_modules folder and after that run npm istall from the cmd.
- 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.
- npm install
- 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
ornpm run serve
.
Most at times, this issue is been caused by broken dependencies. to fix this issue, simple run
yarn install
ornpm 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:
sudo apt-get install python2
rm -rf node_modules
npm i
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):
-
Delete the node_modules
-
Install it again with
npm i