The error “‘vue-cli-service’ is not recognized as an internal or external command” is an error that is invoked whenever you are coding in node.js using vue or cli. Given below is the snippet of the error:
'vue-cli-service' is not recognized as an internal or external command
I would like to share with you the steps I took to fix the “‘vue-cli-service’ is not recognized as an internal or external command” in your project file.
Why “‘vue-cli-service’ is not recognized as an internal or external command” error is seen?
The error, “‘vue-cli-service’ is not recognized as an internal or external command” is seen because; the package @vue/cli-service
must have been installed in your local node_modules in your environment, not your global environment; this is the reason why vue-cli-service cannot be used as a command.
The detailed solution to fix the error “‘vue-cli-service’ is not recognized as an internal or external command”, is given below:
How to fix the error, “‘vue-cli-service’ is not recognized as an internal or external command”?
To fix the error, you will have to install vue/cli-service globally. You can also try to delete your node_modules depending on if you are using yarn or npm in your project file.
To fix the error, “‘vue-cli-service’ is not recognized as an internal or external command”, follow one of the below mentioned steps:
Method 1: Install vue or cli-service globally
To fix the error, “‘vue-cli-service’ is not recognized as an internal or external command”, first, you will have to Install vue/cli-service globally by following the below mentioned command:
npm install @vue/cli-service -g
This will install the global npm package.
@vue/cli-service
is always usually used as a global package, because then you would have to copy and paste these lines to every file in your project.
In case the global npm package is corrupted, then it is not stored in node_modules folder, but rather it depends on the operating system. Locations of the global node_modules folders are given below depending on your operating system.
If you are using Windows operating system:
%USERPROFILE%\AppData\Roaming\npm\node_modules
If you are using Linux based operating system:
/usr/local/lib/node_modules
This should fix the error, “‘vue-cli-service’ is not recognized as an internal or external command”.
Method 2: Delete the node modules
If the error, “‘vue-cli-service’ is not recognized as an internal or external command” is not fixed by following the above step, you can try to delete your node_modules depending on if you are using yarn or npm in your project file.
In order to delete your node modules you can follow the steps given below:
Step 1: First delete your node_modules you can also find your global node modules in the method above.
Step 2: Then in case you are using yarn run yarn
or yarn install
and then yarn serve
Step 3: Finally in case you are using npm run npm install
and then npm run serve
This should fix the error, “‘vue-cli-service’ is not recognized as an internal or external command”.
Conclusion
To fix the error “‘vue-cli-service’ is not recognized as an internal or external command”, you will have to install vue/cli-service globally. You can also try to delete your node_modules depending on if you are using yarn or npm in your project file.