Link to the code that reproduces this issue
https://github.com/unrevised6419/next-upgrade-pnpm-monorepo
To Reproduce
- Clone the repository (pnpm v11 workspace:
apps/web depends on packages/lib via workspace:*, and has @types/react / @types/react-dom installed)
pnpm install
cd apps/web
pnpm dlx @next/codemod@canary upgrade latest (same result with pnpm exec next upgrade)
Current vs. Expected behavior
Current: the codemod writes the @types/react / @types/react-dom overrides to a new apps/web/pnpm-workspace.yaml:
overrides:
'@types/react': 19.3.0
'@types/react-dom': 19.3.0
A pnpm-workspace.yaml marks a workspace root, so apps/web becomes a nested workspace cut off from its siblings, and the codemod's own pnpm install fails:
[ERR_PNPM_WORKSPACE_PKG_NOT_FOUND] In : "@repro/lib@workspace:*" is in the dependencies but no package named "@repro/lib" is present in the workspace
Packages found in the workspace: @repro/web
Error: Failed to install dependencies
catalog: specifiers fail the same way, and plain versions of workspace packages (e.g. 0.0.0) get looked up on the npm registry (ERR_PNPM_FETCH_404). The project is left with the stray pnpm-workspace.yaml and a partially bumped package.json.
Expected: the overrides are written to the existing workspace-root pnpm-workspace.yaml (found by walking up from cwd, the way pnpm locates it), ideally scoped to the upgraded package ('@repro/web>@types/react'), and the install succeeds.
Without @types/react in the app no overrides are written and the upgrade completes, so this only affects TypeScript apps.
Provide environment information
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 27.0.0
Available memory (MB): 16384
Available CPU cores: 8
Binaries:
Node: 22.23.2
npm: 10.9.8
Yarn: N/A
pnpm: 11.21.0
Relevant Packages:
next: 16.2.9 (upgrading to 16.3.5)
react: 19.2.8
react-dom: 19.2.8
typescript: 5.9.3
@next/codemod: 16.4.0-canary.35
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
Introduced in #94690, which moved pnpm v11 overrides into pnpm-workspace.yaml but writes it relative to cwd. Its description notes monorepos were left unchanged; before, a nested pnpm.overrides was silently ignored, but a nested pnpm-workspace.yaml now breaks installation.
Fix proposed in #97412.
Link to the code that reproduces this issue
https://github.com/unrevised6419/next-upgrade-pnpm-monorepo
To Reproduce
apps/webdepends onpackages/libviaworkspace:*, and has@types/react/@types/react-dominstalled)pnpm installcd apps/webpnpm dlx @next/codemod@canary upgrade latest(same result withpnpm exec next upgrade)Current vs. Expected behavior
Current: the codemod writes the
@types/react/@types/react-domoverrides to a newapps/web/pnpm-workspace.yaml:A
pnpm-workspace.yamlmarks a workspace root, soapps/webbecomes a nested workspace cut off from its siblings, and the codemod's ownpnpm installfails:catalog:specifiers fail the same way, and plain versions of workspace packages (e.g.0.0.0) get looked up on the npm registry (ERR_PNPM_FETCH_404). The project is left with the straypnpm-workspace.yamland a partially bumpedpackage.json.Expected: the overrides are written to the existing workspace-root
pnpm-workspace.yaml(found by walking up fromcwd, the way pnpm locates it), ideally scoped to the upgraded package ('@repro/web>@types/react'), and the install succeeds.Without
@types/reactin the app no overrides are written and the upgrade completes, so this only affects TypeScript apps.Provide environment information
Which area(s) are affected? (Select all that apply)
Not sure
Which stage(s) are affected? (Select all that apply)
Other (Deployed)
Additional context
Introduced in #94690, which moved pnpm v11 overrides into
pnpm-workspace.yamlbut writes it relative tocwd. Its description notes monorepos were left unchanged; before, a nestedpnpm.overrideswas silently ignored, but a nestedpnpm-workspace.yamlnow breaks installation.Fix proposed in #97412.