-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Yarn incorrectly warns about unmet peer dependencies #5347
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
Comments
In my case, with yarn v1.5.1 (WSL, node 8.9) I get the message
even though |
Can confirm this is an issue. yarn v1.5.1 |
I encountered something similar where I had the a direct dependency (call it I resolved the issue with a combination of changing the peer dependency semver to Your mileage may vary, however I hope this information helps! |
This is not a bug. Yarn is right to complain here since a peer dependency cannot be reliably satisfied by a depenpency's dependency. This relies on hoisting, which is an opportunistic optimization, not a guarantee. You can read more about this here: https://yarnpkg.com/blog/2018/04/18/dependencies-done-right/ |
Why is this closed? I was just forced into using Yarn (again) on a single project and running a |
I think maybe what people miss reading these (long and numerous) discussions on this particular issue, is what should/could be done to fix the warning. (And who would do it) As I understand it, if a package A declares a peer dependency B, it then becomes the obligation of anyone (say package C) depending on package A to also take a dependency on package B, so that the peer dependency is resolved. So, in any circumstances where the warning shows up:
A concrete example:
In this example it seems that the answer is: firebase should depend on @firebase/app-types directly... The firebase repo already has at least one issue for this: firebase/firebase-js-sdk/issues/541. There they blame yarn, "npm does not do that", but the response here and in other issues against yarn are that this is how yarn works, yarn is not npm, npm is optimistic (if the package is there it's okay, no warning) but yarn is playing it safe. It seems like the only thing to do is to try to get those other package maintainers to accept the reality of how yarn works and please add those dependencies... This seems like the correct course of action to me... And I'm pretty sure it's been explained multiple times (when you know what to look for...) I'm not certain why there is so much friction to adding the dep... it is literally there on node_modules anyway and works due to hoisting, but the philosophy of yarn is that this must be warned about. Also, I guess it is just a warning and can be ignored, but some of us are in the "warnings are like broken windows" school of thought. |
@kitfit-dave Why not? |
For what it's worth, in a monorepo, at monorepo top level,
will add the package at the top level and the warning(s) in question will stop. |
To anybody finding @kitfit-dave 's comment contradictory (regarding the package.json) I think it's because they point to master. If I understand correctly, back when he wrote it, the dependency he talks about was under |
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
In some cases, yarn will report that a peer dependency is unmet even when that dependency is available (as demonstrated by examining node_modules or running
yarn list
).If the current behavior is a bug, please provide the steps to reproduce.
The following is a simplified version of my scenario. I have the following package.json:
When I run
yarn
I get the following warning (among others):However,
@storybook/addons
does get installed at an appropriate version:This makes sense because
@storybook/addons
is a dependency of@storybook/react
.What is the expected behavior?
No peer dependency warning in this case.
Please mention your node.js, yarn and operating system version.
NodeJS: v8.7.0
Yarn: v1.4.1
OS: Windows 10
The text was updated successfully, but these errors were encountered: