1、先安裝nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
#或者 如果wget不存在 執行yum -y install wget
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.11/install.sh | bash
2、在bashrc里面寫下相關配置
#編輯文件
vim ~/.bashrc
#寫入配置
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
3、刷新配置即可正常使用
#刷新配置
source ~/.bashrc
#判斷nvm是否安裝
nvm -v
4、使用nvm下載相關node版本
nvm install 14.13.2
#nvm常用命令
nvm uninstall 14.13.2 // 移除 node 6.11.0
nvm use 14.13.2 // 使用 node 6.11.0
nvm ls // 查看目前已安裝的 node 及當前所使用的 node
nvm ls-remote // 查看目前線上所能安裝的所有 node 版本
nvm alias default 14.13.2 // 使用 6.11.0 作為預設使用的 node 版本