Skip to content

yarn

镜像

  • 查看镜像
sh
yarn config get registry
# 默认镜像源:https://registry.yarnpkg.com
  • 在项目.yarnrc中配置镜像源【项目级】
.yarnrc
ini
registry "https://registry.npmmirror.com"
  • 命令行配置镜像源【全局级】

该命令将更改 当前登录用户 的配置文件

sh
yarn config set registry https://registry.npmmirror.com

.yarnrc

Yarn V1使用的是类ini语法,value如果是字符串需要使用双引号包裹,否则会导致当前key不生效:

ini
registry "https://registry.npmmirror.com"
electron_mirror "https://registry.npmmirror.com/-/binary/electron/"
electron_builder_binaries_mirror "https://registry.npmmirror.com/-/binary/electron-builder-binaries/"

.yarnrc仅支持yarn v1

yarn.yml

Yarn v2+ (Berry) 使用 .yarnrc.yml(YAML 格式):

yaml
npmRegistryServer: "https://registry.npmmirror.com"
enableGlobalCache: true

命令

  • 查看pkg所有的版本
sh
yarn info <pkg> versions