foreword
Applicability : If you occasionally write Vue2 projects and occasionally write Vue3 projects, then a single version of node.js will inevitably report errors, and nvm is very suitable for you Note
: Of course, I hope you can install it smoothly. But please also look carefully at my 标为红色
fonts, which are all summed up after I stepped on one pit after another. Don’t be fooled
at the end : if someone benefits from this article, then the few hours I spent writing the article are meaningful
Article directory
1. Uninstall node.js
1.1 Uninstall
Go to the application installed on the computer and uninstall it here
1.2 Clear the cache (some will report an error later if you do not perform this step)
Open the small black window, execute where node
and where npm
two commands respectively, and then find the corresponding folder according to the directory and delete it, and delete the cache file
注意:若没有将npm的缓存文件删除,后续可能出现 npm 和 node版本对不上导致装包报错!!!
2. Download nvm
2.1 nvm download
GitHub download address: https://github.com/coreybutler/nvm-windows/releases
2.2 After clicking the link, as shown in the figure
2.3 The mouse drum slides down
2.4 Unzip and open after the download is complete
注意一: 安装nvm的路径的每一层级,都不要有空格(正确:D:\Program;错误:D:\Program Files)
注意二:请记住安装nvm的路径,后面会用到
注意:路径要以 node.js 结尾!!!,此处你选了存放文件夹之后,请在后面再手动输入 node.js,如果你是默认路径,那就不管
2.5 Check
Open the small black window, and the version number will come out nvm -v
after , indicating that nvm has been installed successfully, continue to the next step
3. Install multiple node.js versions
3.1 nvm common commands
// 查看当前 nvm 版本号
nvm -v
// 查看已安装的 node.js 版本
nvm list
// 查看可安装的 node 版本
nvm list available
// 安装指定版本的 node (版本号不限)
nvm install 16.14.0
// 使用指定版本的 node
nvm use 16.14.0
3.2 install node
Steps: 1. Download the specified version of node.js ——> 2. Unzip to the folder where nvm is installed ——> 3. Rename the folder (file name format: v16.14.0) ——> 4. nvm install “node Version" --> 5. Command line switch node version --> 6. Finished
3.2.1 Go to node official website to download node
It is recommended to download a version 12 and a version 16.
I use 12.8.0 and 16.14.0, which can be flexibly switched between Vue2 and Vue3 projects
Node.js official website: https://nodejs.org/zh-cn/download/releases/
注意:我是提前准备好的两个不同版本的node。请自行去node.js官网下载并解压过来(3个或更多版本使用亦是同理)
3.2.2 install node
First execute nvm list, check the node version number you decompressed to the nvm folder, and then nvm install "version number" to install the several node versions you decompressed
Four, nvm use
So far, if you can perform the following operations normally (use your own version number for the node version number), it means that the nvm installation is complete
5. Delete nvm
The use of nvm in the fourth step is already done. Delete nvm in this step and leave nvm installation error for those who need to reinstall nvm
5.1 Delete folder
5.2 Delete environment variables