Yarn: "Unmet peer dependency" with peer dependency already installed as transitive dep

Created on 20 Nov 2017  路  6Comments  路  Source: yarnpkg/yarn

To reproduce, just follow the instructions from here: https://github.com/yarnpkg/yarn/issues/2688#issue-207140699

yarn init -y
yarn add [email protected]
yarn add [email protected]

Then you get a warning about missing storyboard-core:

warning " > [email protected]" has unmet peer dependency "storyboard-core@^3.0.0-rc.0".

But it's actually present (as a transitive dependency):

$ yarn list storyboard-core
warning Filtering by arguments is deprecated. Please use the pattern option instead.
鈹斺攢 [email protected]
triaged

Most helpful comment

Okay, I've investigated this and the warning is correct. Transitive dependencies are accepted only if they are on the same tree. Here, storyboard-core comes from storyboard which is installed side-by-side with storyboard-listener-console which is the package that needs storyboard-core as a peer dependency.

There's no guarantee that storbyboard-core would be available to storyvoard-listener-console with this setup since it belongs to a tree under storyboard which doesn't have any intersections with the storyvoard-listener-console tree.

All 6 comments

@Hypnosphi would you mind explaining why this is not the same issue as #4850?

Also, please note that the reason I insisted on creating a new issue was to not forward potential contributors to an already closed and not-so-clear issue so I'd appreciate if you can share a small script snippet that people can copy/paste to reproduce the issue, note your yarn and node versions.

4850's author says:

I've seen multiple issues with the same subject but not the same reason, here React is not a transitive dependency

The steps are exactly the same, honestly I don't understand what's unclear:

$ yarn init -y
$ yarn add [email protected]
$ yarn add [email protected]

Then you get a warning about missing storyboard-core:

warning " > [email protected]" has unmet peer dependency "storyboard-core@^3.0.0-rc.0".

But it's actually present (as a transitive dependency):

$ yarn list storyboard-core
warning Filtering by arguments is deprecated. Please use the pattern option instead.
鈹斺攢 [email protected]

Okay, I've investigated this and the warning is correct. Transitive dependencies are accepted only if they are on the same tree. Here, storyboard-core comes from storyboard which is installed side-by-side with storyboard-listener-console which is the package that needs storyboard-core as a peer dependency.

There's no guarantee that storbyboard-core would be available to storyvoard-listener-console with this setup since it belongs to a tree under storyboard which doesn't have any intersections with the storyvoard-listener-console tree.

There's no guarantee that storyboard-core would be available to storyboard-listener-console with this setup since it belongs to a tree under storyboard which doesn't have any intersections with the storyboard-listener-console tree.

@BYK Could you please explain this a bit more?

I might be totally wrong as my knowledge of yarn and node modules is very limited, but to my knowledge storyboard-core would be installed at the top level node_modules unless it was already installed there with a different version. If that was the case the matching algorithm should check that one.

My statement probably shows my lack of knowledge which is why I asked the original question: could you elaborate what you mean?

Thanks

storyboard-core would be installed at the top level node_modules

It's just an optimization, there's no guarantee that they will keep doing this

Was this page helpful?
0 / 5 - 0 ratings