Install @vue/cli globally
First make sure that node has been installed on the computer (npm will be installed automatically when installing node)
npm install -g @vue/cli
Direct installation using the above command may cause the incompatibility between the node version and the @vue/cli version, as follows: If you ignore
this problem during installation, an error will be reported when you use vue to create a project in the next step:
You are using Node v13.10.1, but this version of @vue/cli requires Node ^12.0.0 || >= 14.0.0.
Solution
1. Switch the version of node
查看当前电脑下安装的node版本:nvm list
切换node版本:nvm use 版本号
Switching node versions does not apply to all situations. In most cases, the version of node is fixed and cannot be modified.
2. Specify the version when installing @vue/cli
npm install -g @vue/[email protected]
Bloggers are also searching for compatible versions of node and @vue/cli, and will continue to update them. If you
have resources, you can share them in the comment area.
Create a vue project with the command
vue create 项目名
The above is just the blogger's own choice, and other functions can also be selected.
run vue project
npm run serve
Summarize
1. Global installation: npm install -g @vue/cli@version number
Check the vue version after installation: vue -V or vue --version
2. Create a vue project: vue create project name
3. Run: npm run serve
Replenish:
The following error occurs when creating a vue project:
Solution:
Step 1: Search for powerShell in the search box in the lower left corner and run it as an administrator
Step 2: Enter Y after entering the following content to change the execution strategy
set-ExecutionPolicy RemoteSigned