ps:copy 别人的,仅仅是存档
- 31594
一、安装brew
终端上运行 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
二、安装nodejs
运行brew install node 即可,但是这样安装的node是最新node,本人安装后是node6.X,node6.X对一些就模块已经不支持了,比如graceful-fs,导致安装一些包的时候,无法运行,就会出现类似 (node:7844) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version 的提示。
三、安装指定版本的node
1、需要安装homebrew-version 安装nvm
brew install nvm
2、查看可安装的node版本
source $(brew --prefix nvm)/nvm.sh 唤醒nvm
nvm ls-remote 查看所有node 版本
nvm install version 就可以安装你想要的版本
3、切换node的版本
nvm use --delete-prefix version