1、安装 Homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
已安装的执行更新 $ brew update
执行诊断 $ brew doctor
并根据提示修复
2、安装 Node
$ brew install node
(更新 $ brew upgrade node
)
执行诊断 $ brew doctor
如遇如下提示:
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Runbrew link
on these:
node
执行
$ brew cleanup
清理brew的link
$ brew link node
3、安装 淘宝 NPM 镜像
$ npm install -g cnpm --registry=https://registry.npm.taobao.org
4、更新NPM
$ npm install npm@latest -g
5、查看Node和NPM版本
$ node -v
$ npm -v
网友评论