1. What is nvm?
.nvm is a node version management tool, which can easily switch, install and view node versions. . . Wait, unlike npm, npm is a management tool for dependent packages.
Second, the installation of nvm.
- Click the following file to install:
(1) installation
Network disk download Extraction code: vpen
If you have installed node separately, it is recommended to uninstall it, and then continue to download from
the official website: nvm , select nvm-setup.zip, and install it directly after downloading
Configure environment variables
(2) Configuration
找到nvm文件位置,点开setting
Then enter the following code after it: (this is the configuration mirror source)
node_mirror: https://npm.taobao.org/mirrors/node/
npm_mirror: https://npm.taobao.org/mirrors/npm/
3. Use
1. Uninstall the previous node.js
2. Open cmd at the location of the nvm file just now
3. Enter the following code to view the node version that nvm can install
nvm ls // 看安装的所有node.js的版本
nvm list available // 查显示可以安装的所有node.js的版本
4. Install the corresponding version.
nvm install 版本号 // 例如:nvm install 14.19.0
5. Switch to the installed version
nvm use 版本号 // 切换到使用指定的nodejs版本
6. Check whether the switching is complete, and open a new cmd
node -v
Fourth, some commands of nvm
nvm command line operation commands
nvm nvm list 是查找本电脑上所有的node版本
- nvm list 查看已经安装的版本
- nvm list installed 查看已经安装的版本
- nvm list available 查看网络可以安装的版本
nvm install 安装最新版本nvm
nvm use <version> ## 切换使用指定的版本node
nvm ls 列出所有版本
nvm current显示当前版本
nvm alias <name> <version> ## 给不同的版本号添加别名
nvm unalias <name> ## 删除已定义的别名
nvm reinstall-packages <version> ## 在当前版本node环境下,重新全局安装指定版本号的npm包
nvm on 打开nodejs控制
nvm off 关闭nodejs控制
nvm proxy 查看设置与代理
nvm node_mirror [url] 设置或者查看setting.txt中的node_mirror,如果不设置的默认是 https://nodejs.org/dist/
nvm npm_mirror [url] 设置或者查看setting.txt中的npm_mirror,如果不设置的话默认的是: https://github.com/npm/npm/archive/.
nvm uninstall <version> 卸载制定的版本
nvm use [version] [arch] 切换制定的node版本和位数
nvm root [path] 设置和查看root路径
nvm version 查看当前的版本