“Unmet peer dependency” with peer dependency already installed as transitive dep

Bug

What is the current behavior?

  1. Install dependency A (with transitive dependency AB)
  2. Later (contrary to #2132), install dependency C (which has AB as peer dep) — an unmet peer dependency warning appears, even though AB was installed in the first step.

Repro

Step 1 output (notice that storyboard-core is installed as a normal dependency of storyboard):

$ yarn init -y
$ yarn add storyboard@3.0.0-rc.1
yarn add v0.19.1
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 13 new dependencies.
...
├─ storyboard-core@3.0.0-rc.0
├─ storyboard@3.0.0-rc.1
...
Done in 4.25s.

Step 2 output (with storyboard-core in its peerDependencies; notice the warning):

$ yarn add storyboard-listener-console@3.0.0-rc.1
yarn add v0.19.1
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
warning "storyboard-listener-console@3.0.0-rc.1" has unmet peer dependency "storyboard-core@^3.0.0-rc.0".
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
└─ storyboard-listener-console@3.0.0-rc.1
Done in 1.36s.

Despite the warning, the installation is successful. Also note that no peer-dep warning appears with npm install.

What is the expected behavior? No warning, since the peer dependency is already installed (with exactly the required version).

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

Node v7.3.0
yarn v0.19.1
Windows 7 (also observed in OS X Sierra)

Author: Fantashit

1 thought on ““Unmet peer dependency” with peer dependency already installed as transitive dep

Comments are closed.

“Unmet peer dependency” with peer dependency already installed as transitive dep

To reproduce, just follow the instructions from here: #2688 (comment)

yarn init -y
yarn add storyboard@3.0.0-rc.1
yarn add storyboard-listener-console@3.0.0-rc.1

Then you get a warning about missing storyboard-core:

warning " > storyboard-listener-console@3.0.0-rc.1" 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.
└─ storyboard-core@3.1.3

Author: Fantashit

1 thought on ““Unmet peer dependency” with peer dependency already installed as transitive dep

  1. 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.

Comments are closed.