Current Behavior:
npm install favors getting higher versions of peer dependencies.
for example:
"@angular/cdk": 10.2.5 has the following peer dependencies
{
...
"@angular/common": "^10.0.0 || ^11.0.0-0",
"@angular/core": "^10.0.0 || ^11.0.0-0"
...
}
"@angular/forms": 10.2.5 has the following peer dependencies
{
...
"@angular/common": "10.2.5",
"@angular/core": "10.2.5"
...
}
if you try to install both packages above you'll get an error because when resolving peer dependencies it chooses "@angular/common": 11.2.11 (and then "@angular/core": 11.2.11) thus results in a conflict
Expected Behavior:
when resolving peer dependencies it should choose "@angular/common": 10.2.5 (and then "@angular/core": 10.2.5) that would have satisfy all deps
Steps To Reproduce:
- open an empty project / folder
- run
npm init (package.json doesn't list any dependencies)
- run
npm i @angular/cdk@10.2.5 @angular/forms@10.2.5
result:
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: @angular/core@11.2.11
npm ERR! node_modules/@angular/core
npm ERR! peer @angular/core@"^10.0.0 || ^11.0.0-0" from @angular/cdk@10.2.5
npm ERR! node_modules/@angular/cdk
npm ERR! @angular/cdk@"10.2.5" from the root project
npm ERR! peer @angular/core@"11.2.11" from @angular/common@11.2.11
npm ERR! node_modules/@angular/common
npm ERR! peer @angular/common@"^10.0.0 || ^11.0.0-0" from @angular/cdk@10.2.5
npm ERR! node_modules/@angular/cdk
npm ERR! @angular/cdk@"10.2.5" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! @angular/forms@"10.2.5" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: @angular/core@10.2.5
npm ERR! node_modules/@angular/core
npm ERR! peer @angular/core@"10.2.5" from @angular/forms@10.2.5
npm ERR! node_modules/@angular/forms
npm ERR! @angular/forms@"10.2.5" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Environment:
npm: 7.11.1
Current Behavior:
npm installfavors getting higher versions of peer dependencies.for example:
"@angular/cdk": 10.2.5 has the following peer dependencies
"@angular/forms": 10.2.5 has the following peer dependencies
if you try to install both packages above you'll get an error because when resolving peer dependencies it chooses "@angular/common": 11.2.11 (and then "@angular/core": 11.2.11) thus results in a conflict
Expected Behavior:
when resolving peer dependencies it should choose "@angular/common": 10.2.5 (and then "@angular/core": 10.2.5) that would have satisfy all deps
Steps To Reproduce:
npm init(package.json doesn't list any dependencies)npm i @angular/cdk@10.2.5 @angular/forms@10.2.5result:
Environment:
npm: 7.11.1