安装目录
mkdir /opt/nvm && cd /opt/nvm
安装包下载
wget https://github.com/nvm-sh/nvm/archive/refs/tags/v0.39.5.tar.gz
注意:https://github.com/nvm-sh/nvm/tags获取新版本或所需版本下载链接并替换
安装包解压
for file in *.tar.gz; do tar -zxvf "$file" --strip-components=1; done
安装包安装
/opt/nvm/install.sh && source ~/.bashrc
常用命令
1.安装特定版本的NodeJS
nvm install
2.切换特定版本的NodeJS
nvm use
3.安装LTS版本NodeJS
nvm install --lts
4.切换LTS版本NodeJS
nvm use --lts
5.查看已安装NodeJS版本
nvm ls
6.查看已安装的LTS版本
nvm ls --lts
7.卸载特定版本的NodeJS
nvm uninstall
8.设置默认的NodeJS
nvm alias default
9.更新NVM
nvm upgrade