2022/01/25, .npmrc, .yarnrc

摘要:通过修改.npmrc/.yarnrc中registry镜像源来加速下载包

npm版

在项目根目录(package.json同一目录)中新建 .npmrc文件,编辑文件内容如下:

sass_binary_site=https://npm.taobao.org/mirrors/node-sass/
phantomjs_cdnurl=https://npm.taobao.org/mirrors/phantomjs/
electron_mirror=https://npm.taobao.org/mirrors/electron/
registry=https://registry.npm.taobao.org 

保存后再使用npm install下载包的速度会快很多

yarn版

在项目根目录(package.json同一目录)中新建 .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"

保存后再使用yarn下载包的速度会快很多

直接修改全局配置

npm config set registry https://registry.npm.taobao.org --global
npm config set disturl https://npm.taobao.org/dist --global

yarn config set registry https://registry.npm.taobao.org --global
yarn config set disturl https://npm.taobao.org/dist --global

相关文章:

  • 2022-12-23
  • 2022-01-07
  • 2021-09-13
  • 2022-12-23
  • 2022-01-21
  • 2022-02-07
  • 2021-11-03
猜你喜欢
  • 2021-05-28
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案