安装或者更新nvm都可以使用安装脚本来进行

1
curl -o- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

或者使用wget

1
wget -qO- https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

执行完命令后有命令行有如下提示

1
2
3
4
5
6
7
8
9
=> nvm is already installed in /root/.nvm, trying to update the script
=> nvm source string already in /root/.bashrc
=> Appending bash_completion source string to /root/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

根据提示复制代码粘贴到.bashrc文件最后,执行source ~/.bashrc更新bash环境

1
source .bashrc