007_Mac上安装Node和NPM

时间:2022-11-17 04:38:54

一、推荐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 '\n#alias for cnpm\nalias 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/