Vue-cli service is not recognized as an internal/external command

I have npm 6.4.1, Node Js 10.15.3.
I have already tried:

  • deleting node_modules folder and running npm install
  • reinstalling NodeJs
  • reinstalling vue cli by running “npm install -g @vue/cli”

I have a package.json file shown below:
This package.json file works for other team members just fine, but does not work for me.

// package.json
{
“name”: “cmsserver”,
“version”: “0.1.0”,
“private”: true,
“scripts”: {
“serve”: “vue-cli-service serve --open”,
“build”: “vue-cli-service build”,
“lint”: “vue-cli-service lint”,
“test:unit”: “vue-cli-service test:unit”
},
“dependencies”: {
“core-js”: “^2.6.5”,
“tracer”: “^0.9.8”,
“vue”: “^2.6.6”,
“vue-router”: “^3.0.1”
},
“devDependencies”: {
@vue/cli-plugin-babel”: “^3.5.0”,
@vue/cli-plugin-eslint”: “^3.5.0”,
@vue/cli-plugin-unit-jest”: “^3.6.3”,
@vue/cli-service”: “^3.5.0”,
@vue/test-utils”: “1.0.0-beta.29”,
“babel-core”: “7.0.0-bridge.0”,
“babel-eslint”: “^10.0.1”,
“babel-jest”: “^23.6.0”,
“eslint”: “^5.8.0”,
“eslint-plugin-vue”: “^5.0.0”,
“vue-template-compiler”: “^2.5.21”
}
}

When I run npm run build, or npm run serve, I get the following error:

‘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! cmsserver@0.1.0 build: vue-cli-service build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the cmsserver@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above

Why doesn’t npm install the vue cli service when I run npm install?
Isn’t that the whole purpose of npm, that it reads then package.json file and installs all the dependencies in the node_modules folder?

1 Like

Have a look at the /node_modules/.bin folder. You should find a file called vue-cli-service there, which is the executable to run.

Does that exist for you?

Nope. the .bin folder only contains two files: mkdirp and mkdirp.cmd.

1 Like

Then npm wasn’t able to install the executable, which could be related to some kind of permissions problem.

Unfortunately I don’t know jack about windows permissions. on OS X I would suspect that either your user isn’t allowed to write executables in the place you have the project, or you run npm with sudo (npm with admin priviliges) which also - couterinuitively - makes npm skip some stuff that shouldn’t be run as admin.

1 Like

Thanks for trying. I have administrator rights on my machine. And this was working last week. I had to uninstall Vue I18n package, and afterwards deleted my node_modules folder, and ran npm install, which I thought would just re-download all my dependencies.

From that point on, I can no longer build Vue apps because of this vue cli error.

1 Like

Hi @beaglebuddy1, one of my coworkers was having this same problem last week. We couldn’t pinpoint exactly what went wrong, but we ended up deleting her local repo and cloning it again from GitHub (not sure if you have your project backed up to a repo or someplace else) and then we ran npm install again. For some reason, it worked this time. No clue why, but I would be very curious if someone has an explanation. Hope you get your vue cli working again!

2 Likes

I had this same issue, running on windows 10. in the /node_modeules/.bin folder there should be a file called vue-cli-service.cmd that got rid of my errors and allowed the build to take place.

1 Like

Not sure if this helps anyone, but I set my NODE_ENV enviroment to “production” on windows and it all blew up. Nothing seemed to work, I tried getting rid of it, so NODE_ENV was blank, and it all still seemed dead. I tried a bunch of fixes, eventually I found that setting NODE_ENV to “development” worked, it installed everything back. I was basically following the advice on this page

https://cli.vuejs.org/config/#publicpath

what I ended up doing was setting my own custom enviroment variable

2 Likes

I was just having this problem and npm install -g @vue/cli worked for me.

2 Likes

Run npm install to get dependencies, vue-cli should run fine after that.
Its a minor issue and this should solve it in most cases.

2 Likes

I had the same problem, then typed “npm install” in cmd just like hajimurtaza said and it solved the problem.

1 Like

I had the same problem,
ran npm install -g @vue/cli like nathan.wailes said,
then ran npm install like hajimurtaza said and it solved the problem.

1 Like

Same problem here. But deleting the entire node_module directory and run npm install solved my problem perfectly.

2 Likes

also deleted node modules then did npm install
it worked

On Windows 10, it is Jan 2020 using vue/cli 4.1.2 yarn v1.21.1

@purplelady105 's solution worked for me! I’m on windows 10 and hadn’t installed @vue/cli or the vue-cli-service(?) globally before doing an npm install in my project. installing both globally, removing the repo locally and then re-cloning it fixed my issue.