Skip to content
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

Peer dependency resolved from sibling, not root #3710

Closed
alunny opened this issue Jun 23, 2017 · 1 comment
Closed

Peer dependency resolved from sibling, not root #3710

alunny opened this issue Jun 23, 2017 · 1 comment

Comments

@alunny
Copy link

alunny commented Jun 23, 2017

Do you want to request a feature or report a bug?

Bug.

What is the current behavior?

As far as I can tell, yarn satisfies peer dependencies by finding the closest match anywhere in the tree. This is unexpected when the top-level project depends on module A at version x, a dependency B depends on module A at version y, and another dependency C peer depends on module A for some version that y satisfies that x does not.

I would expect dependency C to use A@x (what's specified in the top-level package.json file), instead of copying A@y from dependency B.

If the current behavior is a bug, please provide the steps to reproduce.

repro repo is here: https://github.com/alunny/yarn-peerdeps-example

to repro from scratch:

$ yarn init
$ yarn add -D webpack@3.0.0
$ yarn add -D parallel-webpack@1.6.1 # has dependency "webpack": "^1.12.9"
$ yarn add -D karma-webpack@2.0.3 # has peer dependency "webpack": "^1.1.0 || ^2 || ^2.1.0-beta.0 || ^2.2.0-rc.0"
$ grep version node_modules/karma-webpack/node_modules/webpack/package.json
  "version": "1.15.0",
$ yarn why node_modules/karma-webpack/node_modules/webpack/
yarn why v0.23.3
[1/4] 🤔  Why do we have the module "node_modules/karma-webpack/node_modules/webpack/"...?
[2/4] 🚚  Initialising dependency graph...
[3/4] 🔍  Finding dependency...
error We couldn't find a match!
✨  Done in 0.37s.

What is the expected behavior?

Expected karma-webpack to not have its own version of webpack, but use the top-level copy (3.0.0), perhaps with a warning that the peer dependency is not satisfied.

Failing that, perhaps allow yarn install --flat for specific packages (webpack in this case) rather than needing to resolve every duplicate module in the project.

Please mention your node.js, yarn and operating system version.

node v6.10.2
yarn 0.23.3
macOS Sierra 10.12.5

@bestander
Copy link
Member

Thanks for reporting.

This looks crazy, node_modules/karma-webpack/node_modules/webpack/ should not be installed at all and Yarn should display a warning that webpack peer dependency is not satisfied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

3 participants