'vue-cli-service' is not recognized as an internal or external command

avatar

Borislav Hadzhiev

Last updated: Mar 10, 2022

banner

Photo from Unsplash

'vue-cli-service' is not recognized as an internal or external command #

To solve the error "'vue-cli-service' is not recognized as an internal or external command, operable program or batch file", install the @vue/cli-service package globally by running npm install -g @vue/cli-service and clear your npm cache.

First, open your terminal in your project's root directory (where your package.json) file is and run npm install.

shell
npm install npm run serve

If the error is not resolved, try to delete your node_modules and package-lock.json (not package.json) files and re-run npm install.

shell
# 👇️ delete node_modules and package-lock.json rm -rf node_modules rm -f package-lock.json # 👇️ clean npm cache npm cache clean --force npm install
Make sure to restart your IDE and dev server if the error persists. VSCode often glitches and a reboot solves things sometimes.

If that didn't help, install @vue/cli-service globally by running the following command.

shell
# 👇️ uninstall old vue cli npm uninstall vue-cli -g # 👇️ install @vue/cli-service and @vue/cli globally npm install -g @vue/cli-service npm install -g @vue/cli npm run serve
If the global installation of @vue/cli-service fails, you have to open your shell as an administrator or run the command prefixed with sudo.
shell
# 👇️ uninstall old vue cli sudo npm uninstall vue-cli -g # 👇️ install @vue/cli-service and @vue/cli globally sudo npm install -g @vue/cli-service sudo npm install -g @vue/cli npm run serve

Make sure your shell is opened at the root directory of your project (where your package.json file is) when running the npm run serve command.

After installing @vue/cli-service globally and running npm install to install the dependencies in your package.json file, the error should be resolved.

Conclusion #

To solve the error "'vue-cli-service' is not recognized as an internal or external command, operable program or batch file", install the @vue/cli-service package globally by running npm install -g @vue/cli-service and clear your npm cache.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.