vue-cli: vue-cli-service does not run in cmd.exe or Powershell
Version
3.0.0-beta.6
Reproduction link
https://gist.github.com/mrberggg/18d54d105f8cbfa64bd03cb63f9fdfdf
Steps to reproduce
Create a new project with vue cli, then navigate to folder.
In bash run vue-cli-service serve or ./node_modules/.bin/vue-cli-service serve. Serve will work properly.
In Powershell/cmd.exe, run vue-cli-service serve. Will show the following error:
'vue-cli-service' is not recognized as an internal or external command
Try running the service manually by running .\node_modules\.bin\vue-cli-service serve. Will pop open Windows’ ‘How do you want to open this file?’ dialog.
What is expected?
Should run correctly in cmd.exe/Powershell.
What is actually happening?
Does not run.
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 13
- Comments: 20
This was an obscure npm edge case, not related to vue-cli. Was using npm in bash on windows to develop, had to test in cmd.exe. Apparently npm only generates .cmd files for Windows when you run npm install from cmd.exe or Powershell. Deleting node_modules and re-installing from cmd.exe fixes this.
I have such a problem in Windows 10 64bit All is due to --global flag…
npm install --global @vue/cliornpm i -g @vue/cliinstalls node_modules in global routeC:\Users\Username\AppData\Roaming\npmButvue-cli-service serverequires to be loaded in current project module locallySo when installing node modules, it is necessary to put cli without
-gflag:npm i @vue/cliAnd thennpm serveNow it’s workingSimilar problem for me. Deleting node_modules and reinstalling with
yarnfixed my problemnpm install --global @vue/cliI used this command on my bash terminal
And, Then I run vue js app using command
npm startAnd, my terminal shows me and error like,'vue-cli-service'is not recognized as an internal or external command, operable program or batch file.What can i do?
Please, help me,
Happened to me, it turned out when I run
npm install --global @vue/cliit installs vue in Administrator’sAppData\Roaming\npmfolder instead of the current user’sAppData\Roaming\npmfolder.Manually moving the installed files to the current user
AppData\Roaming\npmfolder fixed it.My problem was with Visual Studio 2019 build process. I my case I was able to solve it by providing a more complete path to vue-cli-service in package.json. i.e. `…
“scripts”: { “serve”: “node_modules/.bin/vue-cli-service serve”, “build”: “node_modules/.bin/vue-cli-service build”, “lint”: “node_modules/.bin/vue-cli-service lint” } …` In hindsight probably not of great relevance to this thread, but I got here when looking for a solution to Visual Studio 2019 behaviour with vue projects.
I have had this problem using windows 7, in my case I run
npm iandnpm run servein Visual Studio embebed terminal. The problem was fixed when I deleted node_modules folder and runnpm iandnpm run servein cmd.Hm, using git bash on windows isn’t an obscure edge case.
It’s the only way to develop on windows 😃
Oh I see what you are saying, you ran install on cmd and then ran npm command in bash.