vue 에서 잘 실행하고 있던 vue cli 명령어가 갑자기 아래와 같은 에러를 내며 작동하지 않을 때가 있다.
ex) $npm run serve 명령어 수행시 error
'vue-cli-service' is not recognized as an internal or external command 'vue-cli-service'은(는) 내부 또는 외부 명령, 실행할 수 있는 프로그램, 또는 배치 파일이 아닙니다위와 같은 에러를 해결 하기 위해서는 아래와 같은 2가지 중 하나의 방법을 수행하면 된다.
당연히 node module 과 vue 는 설치 되어있어야 한다.
$ npm install -g vue1. vue cli 재설치 => 삭제후 재설치하여 해결한다.
$ npm uninstall vue-cil -g $ npm install -g @vue/cli2. 1번으로 해결되지 않거나 cmd 에서 사용할 때 주로 해결하는법
먼저 해당 프로젝트의 node_module 폴더 삭제
그 후 $ npm i 명령어로 재설치 후 재기동하면 성공
$ npm run serve
# node_module 폴더 삭제 $ npm i $ npm run serveExample: 'vue' is not recognized as an internal or external command,
I had the same issue.
Here the quick fix.
after running the following command (as Admin)
npm install --global vue-cli
It will place the vue.cmd in the following directory
C:\Users\YourUserName\AppData\Roaming\npm
at least for me it's there.
To use vue as command in cmd. Open the cmd as admin and run the the following command.
setx /M path "%path%;%appdata%\npm"
Now restart the cmd and run the vue again. It should work just fine.
Tags:
Misc Example
Related
everything was installed correctly. but whenever I try to create project, it says "'vue' is not recognized as an internal or external command". I installed and re-installed but didn't work. npm was also added to environmental variable path.
Vuejs is by far the most popular JavaScript framework nowadays. So, if you want to build an appealing and brilliant web application, definitely you should learn Vue. Also, it’s becoming more popular day by day. The job opportunities are a lot for this framework. Besides, they have a community of great and active people who can help you in anytime. So, Vue-CLI is one of the many features of Vue. One of the most common problems that beginners face is how to install and configure it. Furthermore, you will learn how to solve Vue command not found error step by step with an example.
1. What’s Vue-CLI?
In the first place, you must know what’s Vue-CLI? Shortly, Vue-CLI let you install Vue applications or templates with the command line. For instance, when you install Laravel, you use a command line, so, the same case with Vue.
2. How to install Vue-CLI
To install Vue-CLI, you must have Nodejs and Git installed on your system. So, if you don’t have Nodejs, just go to their website and download the current version.
Install Vue-CLI with the following command
npm install -g vue-cliIt will install Vue-CLI globally, which according to the documentation when you install any NPM package globally, you can access it through the command line.
Open your command line and run the following command.
vue init webpack my-projectThe above command normally installs a demo project form Webpack, but you should get an error.
Or your error might be list Vue command not found.
In order to solve this problem, you should add the Vue path to your environment variable manually. So, here is how you can do that.
- Press Win + R
- Type “control sysdm.cpl,,3” and press enter
- Press N to open environment variables.
- Select the path and click Edit.
- Click new to add a new path.
- Paste the path to NPM folder in your AppData.
- Click OK for all windows and you are done.
NPM path is normally in the following folder. Just change your username on your system.
C:\Users\UserName\AppData\Roaming\npmYour show hidden files option must be on the view this files.
You are done now. So, this time if you open the command line and type the following command, it should install the Webpack demo template in the current directory.
vue init webpack my-projectAfter installing, you can run the following command to open the project in the browser.
npm run devSo, it will run a server in the following URL
//localhost:8080/#/Conclusion
All in all, it was that easy. Besides learning what’s Vue-CLI, you learned how to install it from the command line. So, if you have any questions or problems related to how to solve Vue command not found, feel free to comment it below.