平常開發中,可能咱們好幾個項目依賴的NodeJS版本是不一樣的,若是沒有一個合適的管理工具,有時候真的很抓狂,這個時候,就是 nvm 發揮做用的時候了
能夠使用命令node
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
或者使用 Wget
:git
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
安裝完成後最好關閉終端,而後重啓輸入 nvm
驗證是否安裝成功,若是出現Node Version Manager
,說明安裝是成功的。github
但若是提示是bash
command not found: nvm
多是缺乏相應配置致使的,能夠檢查根目錄下的這些文件 (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
,可在底部添加以下代碼:curl
export NVM_DIR="${XDG_CONFIG_HOME/:-$HOME/.}nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
保存並更新配置文件工具
能夠輸入command -v nvm
查看結果url
nvm ls-remote
nvm ls-remote --lts
nvm install v9.5.0
v 後面是想要安裝的版本號spa
nvm ls
nvm use v6.9.0
nvm alias default v6.9.0
打開新的終端,用nvm current
查看當前版本顯示code
nvm uninstall v9.5.0
此過程會花費一點時間blog
nvm install stable
這個根據時間而定,看我的需求使用
友情連接: 官方GitHub