You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Corepack停用或降级Yarn至v1版本?

如何停用Corepack管理的Yarn或降级回Yarn v1

问题背景

我通过以下命令使用Corepack安装并激活了Yarn 3.4.1:

corepack prepare yarn@3.4.1 --activate

验证版本确认安装成功:

yarn -v
3.4.1

现在希望停用Yarn,或者将其降级回系统原本的Yarn v1版本,但查看Corepack 0.12.1的帮助命令后,未找到直接对应的操作选项:

⚡  corepack -h                  
━━━ Corepack - 0.12.1 ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  $ corepack <command>

━━━ General commands ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  corepack disable [--install-directory #0] ...
    Remove the Corepack shims from the install directory

  corepack enable [--install-directory #0] ...
    Add the Corepack shims to the install directories

  corepack hydrate [--activate] <fileName>
    Import a package manager into the cache

  corepack prepare [--activate] [--all] [--json] [-o,--output] ...
    Generate a package manager archive

You can also print more details about any of these commands by calling them with 
the `-h,--help` flag right after the command name.

解决方案

1. 停用Corepack管理的Yarn

执行corepack disable命令移除Yarn的垫片,系统会自动恢复到之前未被Corepack接管的Yarn环境(即原系统的Yarn v1):

corepack disable yarn

若需指定安装目录,可添加--install-directory参数:

corepack disable yarn --install-directory /usr/local/bin

2. 直接降级回Yarn v1

使用corepack prepare命令指定Yarn v1版本并激活,覆盖当前的Yarn 3.4.1:

corepack prepare yarn@1 --activate

执行后验证版本:

yarn -v
# 输出应为v1.x.x系列版本

补充说明

  • 若之前系统未安装过Yarn v1,执行corepack disable yarn后可能出现Yarn命令不可用的情况,此时可通过npm手动安装:
npm install -g yarn@1

内容的提问来源于stack exchange,提问作者Lin Du

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.01 20:25:20