NVM安裝

安裝homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

安裝nvm

$ brew install nvm

設置.bash_profile

export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh

參考:http://my.oschina.net/homeemail?disp=2&p=1&catalog=542671
以mac下爲例,前提:以安裝git

gitclonegit@github.com:creationix/nvm.git /.nvm source ~/.nvm/nvm.sh

安裝

$ nvm install v0.12.0

顯示當前本地安裝的所有 Node.js

$ nvm ls

顯示服務器所有可用的 Node.js

$ nvm ls-remote

本地可用的 Node.js 中使用 0.12.0

$ nvm use 0.12.0

設置每次啓動默認版本

$ nvm alias default 0.12.0

查看正在使用的版本

$ nvm current
v0.10.24
以指定版本執行腳本

$ nvm run 0.10.24 myApp.js
卸載nvm

$ rm -rf ~/.nvm
注意,如果重啓終端後,出現nvm command not found

解決方案:

Check your .bash_profile or .profile file. You most likely had a problem during the installation.

You should have the following at the end of one of those files.

[[ -s HOME/.nvm/nvm.sh ]] && . HOME/.nvm/nvm.sh # This loads NVM
在當前用戶的home目錄裏有個.bash_profile,如果沒有建一個

touch .bash_profile

編輯.bash_profile

vim .bash_profile

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章