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