npm global install / uninstall blocked in yarn/pnpm project if npm enabled
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 42/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- nodejs, typescript
调研方向
从 issue 中的复现命令开始:启用 npm,使用 corepack use yarn 创建 Yarn 项目,然后运行 npm install -g corepack@latest 或将其卸载。阅读 README 中的“Manual Installs > Update Corepack using npm”部分,并跟踪全局安装行为。当 Yarn 或 pnpm 项目中的 npm 全局安装和卸载不再被阻止,或该限制已得到明确记录时,即可视为完成。
由索引模型根据 Issue 内容生成。
描述
Current behavior
If Corepack is enabled for npm and an attempt is made to install Corepack globally when the current working directory (or hierachy above) contains a package.json with packageManager set to yarn or pnpm, then the installation of Corepack fails with a message similar to:
This project is configured to use yarn because /tmp/tmp.XVBPXUZMhT/package.json has a "packageManager" field
This also means that the instructions in the README > Manual Installs > Update Corepack using npm section fail in this situation.
Expected behavior
Global install of Corepack via npm should not be blocked when executing npm install -g or npm uninstall -g in a project configured for Yarn or pnpm and when Corepack is enabled for npm.
Alternatively, the restriction should be documented in the README.
Versions
Corepack 0.31.0
Ubuntu 24.04.2 LTS
Node.js 22.14.0 LTS
Steps to reproduce
export DEBUG=corepack
rm -rf ~/.cache/node/corepack
corepack enable npm
cd $(mktemp -d)
corepack use yarn
corepack -v
npm install -g corepack@latest
corepack -v
Logs
$ export DEBUG=corepack
rm -rf ~/.cache/node/corepack
corepack enable npm
cd $(mktemp -d)
corepack use yarn
corepack -v
npm install -g corepack@latest
corepack -v
Installing yarn@4.8.0 in the project...
corepack Installing yarn@4.8.0 from https://repo.yarnpkg.com/4.8.0/packages/yarnpkg-cli/bin/yarn.js +0ms
corepack Downloading to /home/mike/.cache/node/corepack/v1/corepack-5075-81fd1e1.d12d +1ms
corepack LastKnownGood file would be located at /home/mike/.cache/node/corepack/lastKnownGood.json +280ms
corepack No LastKnownGood version found in Corepack home. +1ms
corepack Download and install of yarn@4.8.0 is finished +0ms
corepack Checking /tmp/tmp.5Ay532aF12/package.json +0ms
corepack Checking /tmp/package.json +0ms
corepack Checking /package.json +0ms
➤ YN0000: · Yarn 4.8.0
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: └ Completed
➤ YN0000: · Done in 0s 52ms
0.31.0
corepack LastKnownGood file would be located at /home/mike/.cache/node/corepack/lastKnownGood.json +0ms
corepack No LastKnownGood version found in Corepack home. +3ms
corepack Search for default version: found in remote registry npm@11.2.0+sha512.3dc9c50ba813a3d54393155a435fe66404b72685ab0e3008f9ae9ed8d81f6104860f07ed2656dd5748c1322d95f3140fa9b19c59a6bba7750fd12285f81866da +1s
corepack Setting npm@11.2.0+sha512.3dc9c50ba813a3d54393155a435fe66404b72685ab0e3008f9ae9ed8d81f6104860f07ed2656dd5748c1322d95f3140fa9b19c59a6bba7750fd12285f81866da as Last Known Good version +0ms
corepack LastKnownGood file would be located at /home/mike/.cache/node/corepack/lastKnownGood.json +1ms
corepack Checking /tmp/tmp.5Ay532aF12/package.json +1ms
This project is configured to use yarn because /tmp/tmp.5Ay532aF12/package.json has a "packageManager" field
0.31.0
- 主要语言
- TypeScript
- 星标
- 3.8k
- 派生
- 279
- 平均合并
- 1 小时 47 分钟
- 30 天内合并 PR
- 2
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
nodejs/corepack 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 64/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 4/5 3-5 天 新手友好度 68/100
-
难度 3/5 1-2 天 新手友好度 52/100
-
难度 3/5 1-2 天 新手友好度 68/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 65/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
bug v2
难度 2/5 1-3 小时 新手友好度 75/100
modelcontextprotocol/inspector#2458 · 1 条评论 ·
-
难度 1/5 1 小时以内 新手友好度 75/100
railmapgen/rmp-gallery#4068 ·
-
Mend: dependency security vulnerability status: needs triage 🕵️♀️
难度 2/5 1-3 小时 新手友好度 70/100
carbon-design-system/ibm-products#9907 ·