使用 nvm 來管理 Node 版本
windows 版本 https://github.com/coreybutler/nvm-windows
mac 版本 https://github.com/creationix/nvm#install-script
nvm安裝成功后,使用nvm命令卻提示command not found,mac終端解決辦法如下:
curl安裝
打開終端鍵入:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
配置環境變量(已有 .bash_profile)
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
配置環境變量(無 .bash_profile)
- 添加 .bash_profile在終端鍵入
touch ~/.bash_profile
- 打開 .bash_profile在終端鍵入
open -e .bash_profile
- 在 .basn_profile中輸入
export NVM_DIR="$HOME/.nvm"
與
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm
兩行代碼
運行配置文件,在終端鍵入
source ~/.bash_profile
查看配置路徑,在終端鍵入
$PATH