1. Install NVM
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
Successful installation by default, a hidden. nvm file is generated in the user folder
Show hidden files:defaults write com.apple.finder AppleShowAllFiles Yes && killall Finder
Hide hidden files:defaults write com.apple.finder AppleShowAllFiles No && killall Finder
2. View the configuration file. bash_profile
No configuration file can be copied and pasted in the. NVM to modify the name of a hidden file, modify the content to the following code: (Note: Nvm_dir points to the user name can be searched in Spotlight "User folder" for viewing)
export NVM_DIR="/Users/你的用户名/.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
3. Make the configuration file. Bash_profile effective (otherwise it will be reported: Nvm:command not found)
source ~/.nvm/.bash_profile
4. NVM Common Commands
The following are examples of 8.9.2 versions
nvm ls :打印出所有的版本nvm install stable:安装最稳定的版本nvm install v8.9.2 : 安装node的8.9.2的版本(删除用uninstall)nvm current :当前使用的node版本nvm use v8.9.2 :将node改为8.9.2版本nvm alias default 0.12.7:设置默认 node 版本为 0.12.7nvm alias default :设置系统默认的node版本nvm alias :给不同的版本号添加别名nvm unalias : 删除已定义的别名nvm reinstall-packages :在当前版本node环境下,重新全局安装指定版本号的npm包npm install -g mz-fis:安装 mz-fis 模块至全局目录,安装的路径:/Users/<你的用户名>/.nvm/versions/node/v0.12.7/lib/mz-fisnvm use 4:切换至 4.2.2 版本(支持模糊查询)npm install -g react-native-cli:安装 react-native-cli 模块至全局目录,安装的路径:/Users/<你的用户名>/.nvm/versions/node/v4.2.2/lib/react-native-cli
Configure NVM in Mac