1.设置国内镜像
a. 设置config
npm config set registry http://registry.npmjs.org
b.编辑~/user/.npmrc
registry=https://registry.npm.taobao.org
2.切换回原npm地址
npm config set registry http://registry.npmjs.org
3.使用nrm管理registry地址
a.安装依赖
npm install -g nrm
b.添加registry地址
nrm add npm http://registry.npmjs.org
nrm add taobao https://registry.npm.taobao.org
c.切换npm registry地址
nrm use taobao
nrm use npm
4.设置单个包的镜像源
npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
npm config set phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
npm config set electron_mirror=https://npm.taobao.org/mirrors/electron/
npm config set registry=https://registry.npm.taobao.org