设置 npm 和 yarn 的镜像源为淘宝镜像源

设置 npm 和 yarn 的镜像源为淘宝镜像源,解决依赖下载很慢的问题。

# ==========================================================
# NPM
# ==========================================================

npm set registry https://r.npm.taobao.org # 注册模块镜像
npm set disturl https://npm.taobao.org/dist # <a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>-gyp 编译依赖的 <a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a> 源码镜像

## 以下选择添加
npm set sass_binary_site https://npm.taobao.org/mirrors/<a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>-sass # <a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>-sass 二进制包镜像
npm set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
npm set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer 二进制包镜像
npm set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver 二进制包镜像
npm set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver # operadriver 二进制包镜像
npm set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs # phantomjs 二进制包镜像
npm set selenium_cdnurl https://npm.taobao.org/mirrors/selenium # selenium 二进制包镜像
npm set <a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>_inspector_cdnurl https://npm.taobao.org/mirrors/<a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>-inspector # <a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>-inspector 二进制包镜像

npm cache clean --force # 清空缓存

# ==========================================================
# YARN
# ==========================================================

yarn config set registry https://r.npm.taobao.org # 注册模块镜像
yarn config set disturl https://npm.taobao.org/dist # <a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>-gyp 编译依赖的 <a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a> 源码镜像

## 以下选择添加
yarn config set sass_binary_site https://npm.taobao.org/mirrors/<a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>-sass # <a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>-sass 二进制包镜像
yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/ # electron 二进制包镜像
yarn config set puppeteer_download_host https://npm.taobao.org/mirrors # puppeteer 二进制包镜像
yarn config set chromedriver_cdnurl https://npm.taobao.org/mirrors/chromedriver # chromedriver 二进制包镜像
yarn config set operadriver_cdnurl https://npm.taobao.org/mirrors/operadriver # operadriver 二进制包镜像
yarn config set phantomjs_cdnurl https://npm.taobao.org/mirrors/phantomjs # phantomjs 二进制包镜像
yarn config set selenium_cdnurl https://npm.taobao.org/mirrors/selenium # selenium 二进制包镜像
yarn config set <a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>_inspector_cdnurl https://npm.taobao.org/mirrors/<a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>-inspector # <a href="http://www.paincker.com/tag/node" rel="tag" title="Posts tagged with node">node</a>-inspector 二进制包镜像

yarn cache clean # 清空缓存

来源:https://gist.github.com/lvxianchao/2dcba1a93422037273dd41a924ddaab9

最后,欢迎扫码关注微信公众号,也可以加我微信 jzj2015 交流(注明来自博客)。

我来评几句
登录后评论

已发表评论数()

相关站点

+订阅
热门文章