Skip to content

UpgradeDependencyVersion: pass --legacy-peer-deps to npm/pnpm#7490

Merged
Jenson3210 merged 1 commit intomainfrom
Jenson3210/install-legacy-peer-deps
Apr 28, 2026
Merged

UpgradeDependencyVersion: pass --legacy-peer-deps to npm/pnpm#7490
Jenson3210 merged 1 commit intomainfrom
Jenson3210/install-legacy-peer-deps

Conversation

@Jenson3210
Copy link
Copy Markdown
Contributor

@Jenson3210 Jenson3210 commented Apr 28, 2026

Summary

The install run inside runInstallInTempDir is purely a validity check on the bumped package.json — the resulting node_modules is not shipped to the user. npm 7+ and pnpm enforce strict peer dependencies by default, which creates false negatives in common ecosystem upgrades (e.g. Angular major bumps, where third-party libs lag the framework's release cadence).

This PR passes --legacy-peer-deps (npm) and --no-strict-peer-dependencies (pnpm) to the temp-dir install so that peer-dep mismatches no longer block the bump from being written. Yarn Classic, Yarn Berry, and Bun are non-strict by default and need no equivalent flag.

Real-world example

Angular 17 → 18 with @ng-bootstrap/ng-bootstrap@16 (peer-pinned to Angular <17) creates a circular peer-dep cascade: bumping Angular alone fails ERESOLVE (because ng-bootstrap@16 still requires <17), and bumping ng-bootstrap@16 → 17 alone fails (ng-bootstrap@17 requires Angular >=18). With strict enforcement, neither bump is ever written and the recipe leaves the user's package.json unchanged. With this change, both bumps are written and the user resolves the install themselves with npm install --legacy-peer-deps (which is the standard Angular ecosystem practice anyway — ng update itself reaches for these flags).

Test plan

  • vitest test/javascript/package-manager.test.ts — all 24 tests pass
  • vitest test/javascript/recipes/upgrade-dependency-version.test.ts — all 25 tests pass (including the two existing tests that exercise markupWarn on install failure, which still pass because --legacy-peer-deps doesn't suppress missing-package or engine-version errors)
  • CI green

The install run inside `runInstallInTempDir` is purely a validity check on
the bumped package.json — the resulting node_modules is not shipped to the
user. npm 7+ and pnpm enforce strict peer dependencies by default, which
creates false negatives in common ecosystem upgrades (e.g. Angular major
bumps, where third-party libs lag the framework's release cadence). When the
strict install fails, `UpgradeDependencyVersion` returns a `markupWarn`
without writing the bump, leaving the user's package.json untouched even
though the bump itself is correct and would resolve under the lenient
behavior they would normally use locally.

Pass `--legacy-peer-deps` (npm) and `--no-strict-peer-dependencies` (pnpm)
to the temp-dir install so that peer-dep mismatches no longer block the
bump from being written. Yarn Classic, Yarn Berry, and Bun are non-strict
by default and need no equivalent flag.
@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Apr 28, 2026
@Jenson3210 Jenson3210 merged commit f192886 into main Apr 28, 2026
1 check passed
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Apr 28, 2026
@Jenson3210 Jenson3210 deleted the Jenson3210/install-legacy-peer-deps branch April 28, 2026 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants