Skip to content

@next/codemod upgrade creates a nested pnpm-workspace.yaml in pnpm v11 monorepos and breaks install #98941

Description

@unrevised6419

Link to the code that reproduces this issue

https://github.com/unrevised6419/next-upgrade-pnpm-monorepo

To Reproduce

  1. Clone the repository (pnpm v11 workspace: apps/web depends on packages/lib via workspace:*, and has @types/react / @types/react-dom installed)
  2. pnpm install
  3. cd apps/web
  4. 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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions