While running a Vue.js project, did you encounter the “vue: command not found” or “vue-cli-service: command not found” error? It can be understandably frustrating for developers to run into such issues when working on a project. Such errors are usually fixable due to their nature, and the number of users who encountered this error found a fix.
Vue CLI is a command-line tool (CLI) for quickly scaffolding and setting up Vue.js projects. It offers a pre-configured build environment with several well-known plugins and loaders for developers to concentrate on developing code rather than spending time configuring.
Applications built with Vue.js are developed using the Vue CLI. A defined file structure, a development server, and many other helpful features enable developers to construct new Vue.js projects swiftly.
Moreover, Vue CLI manages project dependencies and offers a streamlined interface for carrying out typical development chores like running the development server, conducting tests, and preparing the project for production.
In this article, we will discuss the possible ways that you can fix the error that you just encountered in your Vue-CLI-service.
For more information and fixes, we recommend also checking out our other guide catered to solving the ‘vue-cli-service’ is not recognized as an internal or external command error.
Table of Contents
5 Fixes for the Vue or Vue-CLI-Service: Command Not Found Error
1. Vue-CLI-Service Is Not Installed Globally
When you install Vue.js globally on your machine, it does not include the @vue/cli-service package. This is because @vue/cli-service is a development dependency of your Vue.js project, not a global dependency.
Therefore, to use @vue/cli-service, you need to install it globally separately using the following command:
npm install -g @vue/cli-service
The -g flag tells npm to install the package globally, which means it will be available to all of your projects.
Once installed globally, you should be able to run your project without running into the error you encountered before. If not, check out the following other possible solutions.
2. Reinstall the Dependencies
Reinstalling dependencies can be a pretty quick and easy fix to try and see if your error is fixing itself or not.
The node_modules/.bin directory is where npm installs the executable files for your project’s dependencies. When you run a command like vue-cli-service, serve, npm looks for the vue-cli-service executable file in this directory.
To check if the vue-cli-service command exists in the node_modules/.bin directory, navigate to your project’s root directory and run the following command:
If the command exists, it should output the path to the vue-cli-service executable file. If the command does not exist, you may need to reinstall your project’s dependencies.
You can reinstall your project’s dependencies by running the command below:
rm -rf node_modules npm install
The command above will remove the node_modules directory and reinstall all of your project’s dependencies, including @vue/cli-service and its dependencies.
After reinstalling your project’s dependencies, try running the vue-cli-service command again to see if the issue has been resolved.
3. Vue-CLI-Service Not Installed in the Project
The @vue/cli-service development dependency is automatically installed when you create a new Vue.js project using the Vue CLI. But you can run into the error if you already have a project or it’s not installed for another reason.
To fix the issue, you need to install @vue/cli-service locally in your project directory by running the command below:
npm install @vue/cli-service
The command above will install @vue/cli-service in your project’s node_modules directory and add it as a dependency to your project’s package.json file.
4. Vue-CLI-Service Is Not Included in the Project’s Dependencies
In some circumstances, you can see the error because your project’s dependencies don’t contain @vue/cli-service. This can occur if you manually delete the node modules folder after cloning a project from a repository and need to reload your project’s dependencies.
Add @vue/cli-service to your project’s dependencies in the package.json file to fix this issue. You can do this by running the command below:
npm install --save-dev @vue/cli-service
Running the command above will install @vue/cli-service in your project’s node_modules directory and add it as a development dependency to your project’s package.json file.
The –save-dev flag is used when installing a package with npm, and it tells npm to add the package as a development dependency in your package.json file.
Installing a package as a development dependency indicates that it is only needed for testing and development purposes, not for actual runtime or production use. This is helpful if your project just needs certain testing, building, or deployment packages—not for its real functionality.
5. Correct Version of Vue-CLI
You may verify that you have the appropriate @vue/cli-service version installed for the Vue.js version you are running. Using the incorrect version of Vue.js can result in the command not found error because @vue/cli-service is specific to a particular major version of Vue.js.
Not using the correct version is a problem in many of the issues developers face, as new versions usually fix any bugs that the only version might have had that you, as a user, were not experiencing till that moment.
If you use Vue.js 2.x, you should use version 3 of @vue/cli-service. If you use Vue.js 3.x, you should use version 4 of @vue/cli-service.
To check which version of Vue.js you are using, you can run the command below in your project’s root directory:
npm list vue
To install the correct version of @vue/cli-service, you can run the following command:
npm install --save-dev @vue/cli-service@^3.0.0
Or to install version 4:
npm install --save-dev @vue/cli-service@^4.0.0
All the solutions described above will help you troubleshoot why the “vue: command not found” or “vue-cli-service: command not found” error occurs upon running your code. Most of these solutions should fix your issues, and your extension should run quickly.
As mentioned before, gor more information and fixes, we recommend also checking out our other guide catered to solving the ‘vue-cli-service’ is not recognized as an internal or external command error.
Lastly, let us know in the comments:
- Were you also unable to fix issues with your Vue.js running environment?
- Did any of the solutions work for you?
- Is there any missed solution you would like to add to the list?
Feel free to share this article with any of your fellow developers struggling with the “vue-cli-service: command not found” error!