'vue' is not recognized as an internal or external command, operable program or batch file. Causes and solutions

When I was using node.js today, the following error occurred:

C:\Users\xiesj> vue -v
'vue'不是内部或外部命令,也不是可运行的程序或批处理文件。

reason:

1. Determine whether npm has been installed correctly?

2. Are you sure that vue and vue-cli have been installed correctly?

3. Are you sure vue.cmd has been added to the environment variables?

Solution

Once you know the reason, it will be much easier to solve it. The specific steps are as follows:

1. Determine whether npm has been installed correctly and enter the following command in cmd:

C:\Users\xiesj> npm -v

As you can clearly see from the picture above, I have already installed it

2. Enter npm config list to view the directory

Find the corresponding address in the prefix directory

Then check if there are Vue related executable files in the directory.

If you cannot see this instruction, return to the cmd command window console and execute the following command to install vue :

C:\Users\xiesj> npm install -g vue

Then, enter the following command to install vue-cli :

// 卸载
npm uninstall -g vue-cli

// 安装
npm install -g @vue/cli 

// 或者
cnpm install -g @vue/cli 

 Vue has been installed, you can see it.

Execute if any

vue --version 

vue -V

vue-cli --version

If there is no problem, the problem lies in not configuring npm to add the globally downloaded package to the environment variable.

3. Find "System and Security" in "Control Panel", then find "System" in "System and Security". After finding the system interface, find "Advanced System Settings" in the sidebar on the left and click to enter.

4. After clicking in, find the "Environment Variables" button in the Advanced tab and click in.

5. After clicking in, select the path line in the "System Variables" section, and then click the "Edit" button below.

6. After clicking in, select the "New" button on the page

7. In the last line of the new page, add the path after the prefix queried in the first step, then click "OK", and click OK on the next page to complete the setting.

C:\Program Files\nodejs\node_global

Guess you like

Origin blog.csdn.net/lovedingd/article/details/132169939