vue-cli-service does not run in cmd.exe or Powershell

Created on 12 Apr 2018  路  17Comments  路  Source: vuejs/vue-cli

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.

Most helpful comment

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.

All 17 comments

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.

Similar problem on beta10. had many " vue-loader was used without the corresponding plugin errors" after a clean vue create. Fixed it by using CMD instead of PowerShell

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.

Happened to me, it turned out when I run npm install --global @vue/cli it installs vue in Administrator's AppData\Roaming\npm folder instead of the current user's AppData\Roaming\npm folder.

Manually moving the installed files to the current user AppData\Roaming\npm folder fixed it.

Similar problem for me. Deleting node_modules and reinstalling with yarn fixed my problem

I have had this problem using windows 7, in my case I run npm i and npm run serve in Visual Studio embebed terminal. The problem was fixed when I deleted node_modules folder and run npm i and npm run serve in cmd.

I have had this problem using windows 7, in my case I run npm i and npm run serve in Visual Studio embebed terminal. The problem was fixed when I deleted node_modules folder and run npm i and npm run serve in cmd.

it's so working

I have such a problem in Windows 10 64bit
All is due to --global flag...
npm install --global @vue/cli or npm i -g @vue/cli installs node_modules in global route C:\Users\Username\AppData\Roaming\npm
But vue-cli-service serve requires to be loaded in current project module locally

So when installing node modules, it is necessary to put cli without -g flag: npm i @vue/cli
And then npm serve
Now it's working

uninstalled / reinstalled Node/NPM, tried all the recommendations here but nothing is working. Can't get vue CLI to execute npm run serve with or without running cmd/powerShell as Administrator on windows 10 ...

None of the above worked for me, but I think my problem was related to WSL. Sometimes when I check out a repo using WSL it causes some weird case-sensitivity issues when I try to do things in that directory from cmd. I checked out my project using git in cmd rather than WSL, and everything started to work as expected.

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.

npm install --global @vue/cli

I used this command on my bash terminal

And, Then I run vue js app
using command npm start
And, my terminal shows me and error like,

vue-cli-service serve

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

What can i do?

Please, help me,

You can try to delete the node_modules directory and install it again with npm install.
In my case I copied the node_modules directory from a linux installation and apparently windows needs to create its own files.

Bitdefender (and perhaps other antivirus software) prevents a Windows process from launching a new console because it blocks access to conhost.exe. Thus npm run serve was failing silently for me. I do not have the option of changing the way Bitdefender works, so I have worked around the problem by using the cygwin console instead of cmd or Powershell.

try running command prompt as administrator if your account is an administrator account, and run npm install --global @vue/cli. if it still doesn't work run npm uninstall --global @vue-cli to uninstall previous versions of Vue. then run npm install --global @vue/cli to install Vue

"npm i" has fixed the issue for me

Still facing the same issue for Windows. I've been trying to delete node_modules inside my project, reinstalling again. Create another vue project. The problem still showing up.
At first, I thought because my vue-cli isn't updated yet, but it seems that npm run <script_name> will use the global modules instead of the one that installed in my project.

Using absolute path to the vue-cli-service (ex: .\node_modules\.bin\vue-cli-service serve via PowerShell) inside the project's node_modules solves the issue for me.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

csakis picture csakis  路  3Comments

PrimozRome picture PrimozRome  路  3Comments

OmgImAlexis picture OmgImAlexis  路  3Comments

BusyHe picture BusyHe  路  3Comments

chasegiunta picture chasegiunta  路  3Comments