Skip to content

Yarn 换源命令已过时 #53

@MrWillCom

Description

@MrWillCom

对 npm 等换源时,发生如下错误:

❯ chsrc set npm
[chsrc 检查] ✓ 命令 npm 存在
[chsrc 检查] ✓ 命令 yarn 存在
[chsrc 检查] ✓ 命令 pnpm 存在
[chsrc 检查] ✓ 命令 curl 存在
测速 https://npmmirror.com/ ... 6.27 MByte/s
测速 https://mirrors.huaweicloud.com/ ... 6.93 MByte/s
测速 https://mirrors.zju.edu.cn/ ... 8.41 MByte/s
最快镜像站: 浙江大学开源软件镜像站
选中镜像站: ZJU (zju)
--------------------------------
[chsrc 运行] npm config set registry https://mirrors.zju.edu.cn/npm
[chsrc 运行] ✓ 命令执行成功

[chsrc 运行] yarn config set registry https://mirrors.zju.edu.cn/npm
Usage Error: Couldn't find a configuration settings named "registry"

$ yarn config set [--json] [-H,--home] <name> <value>
[chsrc 运行] x 命令执行失败,返回码 256
chsrc: 关键错误,强制结束

事实上,自 Yarn v2 开始,全局换源的指令变更为了:

$ yarn config set npmRegistryServer -H <registry>

以下文档可供参考:


此外,如果已在 npm 中配置全局镜像源,且 pnpm 中没有配置自定义源,那么 pnpm 会默认跟随 npm 的配置而不需要额外对之单独配置。当然,对三个包管理器都执行配置镜像源的命令也是一种更可靠的做法。

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions