1、配置到淘宝服务器
# 配置到淘宝服务器
npm config set registry https://registry.npm.taobao.org
# 查看 registry 是否配置正确
npm config get registry
复制 文本
2、对下载包设置镜像
npm config set sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
npm config set phantomjs_cdnurl "http://cnpmjs.org/downloads"
npm config set electron_mirror "https://npm.taobao.org/mirrors/electron/"
npm config set sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
npm config set profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
npm config set chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"
复制 文本
3、通过文件配置
项目根目录创建.npmrc或者.yarnrc
registry "https://registry.npm.taobao.org"
sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
phantomjs_cdnurl "http://cnpmjs.org/downloads"
electron_mirror "https://npm.taobao.org/mirrors/electron/"
sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"