NPM加速配置

本文介绍了如何加速NPM和Yarn的下载速度,通过设置淘宝镜像和自定义 registry,确保更快地获取包资源。对于Yarn,详细列出了配置命令和.yarnrc文件内容;对于npm,同样给出了配置命令及.npmrc文件示例。此外,还展示了已配置的npm和Yarn的配置信息,包括sass_binary_site和自定义registry。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

NPM加速

yarn

命令行

yarn config set "sass_binary_site" "http://cdn.npm.taobao.org/dist/node-sass"
yarn config set "@xxxxx:registry" "https://registry-npm.xxxxx.com"
yarn config set "registry" "https://registry.npm.taobao.org/"

.yarnrc

"registry" "https://registry.npm.taobao.org/"
"@xxxxx:registry" "https://registry-npm.xxxxx.com"
"sass_binary_site" "http://cdn.npm.taobao.org/dist/node-sass"

npm

命令行

npm config set "sass_binary_site" "http://cdn.npm.taobao.org/dist/node-sass"
npm config set "@xxxxx:registry" "https://registry-npm.xxxxx.com"
npm config set "registry" "https://registry.npm.taobao.org/"

.npmrc

"registry"="https://registry.npm.taobao.org/"
"sass_binary_site"="http://cdn.npm.taobao.org/dist/node-sass"
"@xxxxx:registry"="https://registry-npm.xxxxx.com"

查看配置

npm config list

; "user" config from /Users/shang/.npmrc

//registry.npmjs.com/:_authToken = (protected)
electron_mirror = "https://npm.taobao.org/mirrors/electron/"
profiler_binary_host_mirror = "https://npm.taobao.org/mirrors/node-inspector/"
; registry = "https://registry.npm.taobao.org/" ; overridden by project
sass_binary_site = "https://npm.taobao.org/mirrors/node-sass/phantomjs_cdn"
sqlite3_binary_host_mirror = "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
url = "http://cnpmjs.org/downloads"

; "project" config from /Users/shang/Code/kmos/kmos/.npmrc

@xxxxxx:registry = "https://registry-npm.xxxxxx.com"
registry = "https://registry.npm.taobao.org/"

; node bin location = /usr/local/bin/node
; cwd = /Users/shang/Code/kmos/kmos
; HOME = /Users/shang
; Run `npm config ls -l` to show all defaults.

yarn config list

yarn config v1.22.17
info yarn config
{
  'version-tag-prefix': 'v',
  'version-git-tag': true,
  'version-commit-hooks': true,
  'version-git-sign': false,
  'version-git-message': 'v%s',
  'init-version': '1.0.0',
  'init-license': 'MIT',
  'save-prefix': '^',
  'bin-links': true,
  'ignore-scripts': false,
  'ignore-optional': false,
  registry: 'https://registry.npm.taobao.org/',
  'strict-ssl': true,
  'user-agent': 'yarn/1.22.17 npm/? node/v16.13.1 darwin x64',
  '@base:registry': 'https://registry-npm.xxxxxx.com',
  '@xxxxxx:registry': 'https://registry-npm.xxxxxx.com',
  lastUpdateCheck: 1644378532337,
  sass_binary_site: 'http://cdn.npm.taobao.org/dist/node-sass',
  'omit.js': 'https://registry.npmjs.org/omit.js',
  '@ant-design:registry': 'https://registry.npm.taobao.org'
}
info npm config
{
  registry: 'https://registry.npm.taobao.org',
  sass_binary_site: 'https://npm.taobao.org/mirrors/node-sass/phantomjs_cdn',
  url: '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/',
  '//registry.npmjs.com/:_authToken': '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',
  '@xxxxxx:registry': 'https://registry-npm.xxxxxx.com'
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

从未、淡定

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值