007_Mac上安装Node和NPM

一、推荐brew来对node和npm版本进行管理。

<1>确保brew是安全可靠的,代码如下:
$ brew doctor

#直接install node会有以下报错https://github.com/Homebrew/homebrew-core/issues/11713,所以执行下面的命令
brew uninstall node icu4c
brew install node
<2>测试Node和npm安装是否成功,安装Grunt
npm install -g grunt-cli

二、更改为淘宝的源

https://npm.taobao.org/

echo '
#alias for cnpm
alias cnpm="npm --registry=https://registry.npm.taobao.org 
  --cache=$HOME/.npm/.cache/cnpm 
  --disturl=https://npm.taobao.org/dist 
  --userconfig=$HOME/.cnpmrc"' >> ~/.zshrc && source ~/.zshrc

Reference:

https://www.jianshu.com/p/20ea93641bda

https://npm.taobao.org/

原文地址:https://www.cnblogs.com/arun-python/p/9046188.html