安裝nvm
brew install nvm
在shell中可以使用nvm命令
如果沒有.bash_profile文件需要自行touch .bash_profile哦
$ cd ~
$ vim .bash_profile
編輯.bash_profile文件輸入,本人不會(huì)用vim 所以用編輯器輸入
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
然后重新source
source .bash_profile
使用nvm安裝node
nvm ls-remote
#查看 所有的node可用版本
nvm install xxx
#下載你想要的版本
nvm use xxx
#使用指定版本的node
nvm alias default xxx
#每次啟動(dòng)終端都使用該版本的node