UpgradeDependencyVersion: pass --legacy-peer-deps to npm/pnpm#7490
Merged
Jenson3210 merged 1 commit intomainfrom Apr 28, 2026
Merged
UpgradeDependencyVersion: pass --legacy-peer-deps to npm/pnpm#7490Jenson3210 merged 1 commit intomainfrom
Jenson3210 merged 1 commit intomainfrom
Conversation
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.
greg-at-moderne
approved these changes
Apr 28, 2026
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The install run inside
runInstallInTempDiris purely a validity check on the bumpedpackage.json— the resultingnode_modulesis 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).UpgradeDependencyVersionreturns amarkupWarn(UpgradeDependencyVersion: warn on install failure instead of throwing #7479) without writing the bump, leaving the user'spackage.jsonuntouched even though the bump itself is correct and would resolve under the lenient behavior they would normally use locally (npm install --legacy-peer-deps).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'spackage.jsonunchanged. With this change, both bumps are written and the user resolves the install themselves withnpm install --legacy-peer-deps(which is the standard Angular ecosystem practice anyway —ng updateitself reaches for these flags).Test plan
vitest test/javascript/package-manager.test.ts— all 24 tests passvitest test/javascript/recipes/upgrade-dependency-version.test.ts— all 25 tests pass (including the two existing tests that exercisemarkupWarnon install failure, which still pass because--legacy-peer-depsdoesn't suppress missing-package or engine-version errors)