-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] failed to resolve peer dependencies (conflict) when peer dependencies are in range. #3152
Comments
this is one we intend to resolve in some fashion, but it is surprisingly complicated with the current state of arborist. as a work around for now you can specify |
@nlf thanks, i really appreciate your suggestion for a workaround but this is merely an example to demonstrate the nature of the issue. The real issue I'm facing is more complicated than the example above- i actually want to rely on npm to install peer dependencies correctly and to fail when it finds conflicts. There are however many published libraries that will fail to install without a workaround. |
yup, totally understood. we're working on it but this one creates a huge amount of complexity so it may be some time before we come up with a solution that resolves as many conflicts as it possibly can without introducing massive slow downs. |
In cases where a peerSet _partially_ overlaps another, we were previously treating that as a conflict, because not everything in the peerSet was being replaced. So for example, ``` root -> (a) a -> PEER(w@1, x@1, y@1) b -> PEER(x@1.0, y@1.0, z@1.0) ``` First we install, and get `w@1.1.0`, `x@1.1.0` and `z@1.1.0`. Then, we try to install `b`, and need to install the `1.0.0` versions of `x` and `y`. We could replace `x` and `y`, but then `z` had no replacement, and was treated as an ERESOLVE mistakenly. Some work was required to make it still note when a not-replaced member of the peer set _is_ indicative of a conflict, because it depends on a version of a dep within the peer set that is not satisfied by the one being replaced. Fix: npm/cli#3152
In cases where a peerSet _partially_ overlaps another, we were previously treating that as a conflict, because not everything in the peerSet was being replaced. So for example, ``` root -> (a) a -> PEER(w@1, x@1, y@1) b -> PEER(x@1.0, y@1.0, z@1.0) ``` First we install, and get `w@1.1.0`, `x@1.1.0` and `z@1.1.0`. Then, we try to install `b`, and need to install the `1.0.0` versions of `x` and `y`. We could replace `x` and `y`, but then `z` had no replacement, and was treated as an ERESOLVE mistakenly. Some work was required to make it still note when a not-replaced member of the peer set _is_ indicative of a conflict, because it depends on a version of a dep within the peer set that is not satisfied by the one being replaced. Fix: npm/cli#3152
In cases where a peerSet _partially_ overlaps another, we were previously treating that as a conflict, because not everything in the peerSet was being replaced. So for example, ``` root -> (a) a -> PEER(w@1, x@1, y@1) b -> PEER(x@1.0, y@1.0, z@1.0) ``` First we install, and get `w@1.1.0`, `x@1.1.0` and `z@1.1.0`. Then, we try to install `b`, and need to install the `1.0.0` versions of `x` and `y`. We could replace `x` and `y`, but then `z` had no replacement, and was treated as an ERESOLVE mistakenly. Some work was required to make it still note when a not-replaced member of the peer set _is_ indicative of a conflict, because it depends on a version of a dep within the peer set that is not satisfied by the one being replaced. Fix: npm/cli#3152
In cases where a peerSet _partially_ overlaps another, we were previously treating that as a conflict, because not everything in the peerSet was being replaced. So for example, ``` root -> (a) a -> PEER(w@1, x@1, y@1) b -> PEER(x@1.0, y@1.0, z@1.0) ``` First we install, and get `w@1.1.0`, `x@1.1.0` and `z@1.1.0`. Then, we try to install `b`, and need to install the `1.0.0` versions of `x` and `y`. We could replace `x` and `y`, but then `z` had no replacement, and was treated as an ERESOLVE mistakenly. Some work was required to make it still note when a not-replaced member of the peer set _is_ indicative of a conflict, because it depends on a version of a dep within the peer set that is not satisfied by the one being replaced. Fix: npm/cli#3152
Hey @talsi , does npm 7.11.2 work for you? |
hi, for example,
steps to reproduce are: result:
|
This is because we are installing directly from git instead of via npmjs.com so we need to make sure that npm builds the libraries af- ter installing. The caveat is that we need to use --legacy-peer-deps when building md-menu because of some bug in npm that causes it to prefer higher versions when range is given: > npm ERR! Could not resolve dependency: > npm ERR! peer @angular/common@"10.2.5" from @angular/forms@10.2.5 > npm ERR! node_modules/@angular/forms > npm ERR! peer @angular/forms@"^9.0.0 || ^10.0.0-0" from @angular/material@9.2.4 > npm ERR! node_modules/@angular/material > npm ERR! peer @angular/material@">=7.0.0 <10.0.0" from the root project See: npm/cli#3152
This is because we are installing directly from git instead of via npmjs.com so we need to make sure that npm builds the libraries af- ter installing. The caveat is that we need to use --legacy-peer-deps when building md-menu because of some bug in npm that causes it to prefer higher versions when range is given: > npm ERR! Could not resolve dependency: > npm ERR! peer @angular/common@"10.2.5" from @angular/forms@10.2.5 > npm ERR! node_modules/@angular/forms > npm ERR! peer @angular/forms@"^9.0.0 || ^10.0.0-0" from @angular/material@9.2.4 > npm ERR! node_modules/@angular/material > npm ERR! peer @angular/material@">=7.0.0 <10.0.0" from the root project Also, it seems the npm postinstall was not necessary. See: npm/cli#3152
We need this because we are installing directly from git instead of via npmjs.com so we need to make sure that npm builds the libraries after installing. The caveat is that we need to use --legacy-peer-deps when building md-menu because of some bug in npm that causes it to prefer higher versions when range is given (we have @angular/forms@^9.0.0...): > npm ERR! Could not resolve dependency: > npm ERR! peer @angular/common@"10.2.5" from @angular/forms@10.2.5 > npm ERR! node_modules/@angular/forms > npm ERR! peer @angular/forms@"^9.0.0 || ^10.0.0-0" from @angular/material@9.2.4 > npm ERR! node_modules/@angular/material > npm ERR! peer @angular/material@">=7.0.0 <10.0.0" from the root project Also, it seems the npm postinstall was not necessary. See: npm/cli#3152
@isaacs it still happens to me using 7.24.2 |
Has there been any progress on this issue? |
@Quazmoz it's fixed. try npm 8 latest, and if you're getting an error like the above, then it means your dependency graph is invalid, and the error message explains why. |
@Quazmoz @ljharb |
@talsi it's not always going to be possible (in a P=NP sense) to pick the right version; it's not really a bug that sometimes you have to do it yourself and explicitly add a peer dep (all your peer deps should be explicitly added anyways). It seems like your project already depends on v13.2.2 of I think you need to downgrade |
@ljharb I can't control the peer dependencies of 3rd party libs. If the default settings in npm 7 is to install peer dependencies then it shoud work flawlessly. That's the reason why it was removed after version 3. For experienced developers this can be just a minor issue but new ones will immediately start using yarn or anything else that works for them. I truly understand the complexity of this issue i just think that if there are no plans to fix this issue maybe it'll better to have users opt-in to use this feature instead of closing all of the bugs users open about it and keeping it as the the default setting. I honstly don't understand how come this issue don't get more attention. |
@talsi indeed, you can't. which is why in this case you'd need to add |
why this issue is closed? it still happening in June 2022 @ljharb |
I am still facing this issue. |
@faizaldong because the bug is likely in your package.json, not in npm |
Current Behavior:
npm install
favors 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.5
result:
Environment:
npm: 7.11.1
The text was updated successfully, but these errors were encountered: