项目地址
https://github.com/nvm-sh/nvm
一、安装NVM
1、安装nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
或者
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
2、运行脚本后,使当前环境变量生效。(也可以重新连接会话)
source ~/.bashrc
二、安装 node
1、查看nvm所有的版本
nvm ls-remote
2、安装需要的指定版本,如v10.24.1
nvm install v10.24.1
3、查看当前已经安装的版本
nvm list
4、切换版本
nvm use v14.17.3
5、卸载指定版本(如果使用当前版本需要切换后才能卸载)
nvm uninstall v14.17.3