When vue create creates a project, it prompts that 'vue' is not an internal or external command, nor is it a runnable program or batch file after using nvm to switch node

Prospect: I am using the node version switched by nvm instead of installing the advanced version of node directly. If you are also confused by nvm, you can use the following methods to solve the problem, come on! ! !

Error:
'vue' is not recognized as an internal or external command, operable program or batch file

Solution:
1. Check node and npm

node -v
npm -v

2. If there is, install vue and vue-cli scaffolding-g: global installation

npm install  vue -g
npm install  vue-cli -g
vue -V 检查是否成功安装

3. Find the locally installed nvm folder globally
Example: Create folder node_global/ node_cache under D://NVM/nvm

Configure global node_global#
1. Create node_global and node_cache folders in the node installation directory
2. Configure node_global and node_cache (cache area)

insert image description here
4. Modify the global operating environment: system h environment variable path: add node_global
D:\NVM\nvm\node_global
can be modified to your own path:

5. After the settings are modified

root: D:\NVM\nvm 
path: D:\NVM\nvm-nodejs 
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/

Re-execute cmd to the current folder
and then vue create front to create the project

An error was reported:
Error: command failed: yarn error was reported

This problem is actually a path problem. The path carries Chinese, change the Chinese to English, and then reinstall node to create files using vue create normally.

After the modification, an error was reported again:
insert image description here
Solution:
Modify the local and enter the Windows environment.
There is a file under C:/users/admin/. Vuerc
insert image description here
opens the file yarn through the editor
and changes it to npm

{
  "useTaobaoRegistry": true,
//  "packageManager": "yarn"
   "packageManager": "npm"
}

Re-execute the command to create the next project to solve it.

vue create front

cd 当前文件夹
npm run serve

insert image description here
Summary: record it, avoid detours! ! !

Guess you like

Origin blog.csdn.net/weixin_46409887/article/details/127868221