Repository navigation
fix(core): drop the unused optional @angular/platform-server peer - #3792
armando-navarro wants to merge 1 commit into
Conversation
npm 10, and npm 11 before 11.20, resolve a missing optional peer anyway while installing. For an app whose package.json uses caret ranges and whose Angular is one patch behind the newest, npm picks the newest @angular/platform-server, which requires that exact newest @angular/core, and the install stops with ERESOLVE. Every current Node line bundles one of those npm versions. Nothing in the published package imports @angular/platform-server, so the peer is removed. Apps that render on the server still install it themselves, as they already do.
tyler-reitz
left a comment
There was a problem hiding this comment.
LGTM. Reproduced the failure and the fix rather than reading them.
On an Angular 21.2.24 app with ^21.2.0 ranges, npm 10.9.9 plus the published 21.0.0-rc.1 stops with the error you quote, chained through peerOptional @angular/platform-server@"^21.2.0" from @angular/fire. The same app installs with 21.0.0-rc.1 repacked minus those two lines, leaving @angular/core at 21.2.24, and installs with the unmodified package on npm 11.20.0.
One thing worth knowing if anyone re-runs this: a minimal app (core, common, compiler, platform-browser) does not reproduce it on any npm version. The exact pins @angular/build brings in are what force the conflict, so a repro without the CLI dev dependencies looks clean and isn't.
Confirmed separately that nothing in the published tarball imports @angular/platform-server. The only mention is a code sample in docs/universal/prerendering.md where the app imports it, which this does not affect since such an app installs it directly. Root package.json, tools/jasmine.ts and sample/package.json keep it, which is right since they are dev and test only.
Refs #3667
Removes the optional
@angular/platform-serverpeer from the published package, which no file in the package imports. On npm 10, and on npm 11 before 11.20, that peer alone makes installing AngularFire fail on an app whose Angular is one patch behind the newest.Cause
@angular/platform-servermatching AngularFire's range, which is 21.2.25 today.@angular/platform-serverrelease requires its own exact@angular/coreversion, so 21.2.25 asks for@angular/core21.2.25.package.jsonsays^21.2.0and which has 21.2.24 installed,@angular/commonand the other Angular packages require@angular/core21.2.24 exactly, so npm stops withConflicting peer dependency: @angular/[email protected].@angular/platform-server, is not affected.Changes
src/package.json: drops@angular/platform-serverfrompeerDependenciesandpeerDependenciesMeta. The rootpackage.jsonkeeps it as a dev dependency for the test runner.Behavior to know
21.0.0-rc.1and20.1.0still declare this peer, so the fix reaches@nextand@latestinstalls only with the next release on each line. A cherry-pick to20.1.xfollows this PR.@angular/platform-serverfrom another major. That pairing still fails, because@angular/platform-serverrequires the app's exact@angular/core.Verification
^21.2.0ranges,npm install --package-lock-onlyof the current canary fails withConflicting peer dependency: @angular/[email protected]on npm 10.8.2, 10.9.8, 10.9.9, 11.0.0, 11.19.0, 11.19.1 and 12.0.2, and installs on 11.20.0, 11.21.0, 12.1.0 and 12.2.0.@angular/coreleft at 21.2.24.@angular/[email protected]fails the same way on an Angular 20.3.32 app on npm 10.9.9, and installs once the peer is removed.@angular/platform-server21.2.24 installs before and after this change.21.0.0-rc.1,20.1.0or the package built from this branch imports@angular/platform-server. Only a docs page mentions it.