Yarn: Bug or expected behavior with the transitive dependency "reusing"?

Created on 25 Sep 2017  Â·  7Comments  Â·  Source: yarnpkg/yarn

Hello. I found some strange behavior. Is this a bug or is it an expected behavior?

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

What is the current behavior?
Please see below.

If the current behavior is a bug, please provide the steps to reproduce.
I have the following package.json:

{
  "name": "pm-playground",
  "private": true,
  "dependencies": {
    "babel-cli": "6.26.0",
    "core-js": "2.4.1"
  }
}

I run yarn install and now I have the following directories hierarchy in node_modules:

    …
    [email protected]
        node_modules
            [email protected]
    [email protected]
    …

babel-cli has babel-runtime^6.26.0 in the dependencies. babel-runtime has core-js@^2.4.0 in the dependencies, so top-level [email protected] should satisfy babel-runtime requirement, but Yarn installed [email protected] instead of "reusing" the top-level [email protected].

What is the expected behavior?
I expect the following node_modules directory structure:

    …
    [email protected]
    [email protected]
    …

[email protected] is "reusing" the top-level [email protected] and does not install [email protected].

Please mention your node.js, yarn and operating system version.
Node.js - 8.5.0
Yarn - 1.1.0
OS - Win 10

Most helpful comment

@vkrol yup. I'd create an issue in the website repo and ping @arcanis about it. We may also try adding a check about possible duplicates in the tree and show people an info message about this.

All 7 comments

Seeing the same issue for multiple packages across different repos after updating to v1.1.0. Removing the lock-file and re-creating it seems to resolve it.

@simonkberg in my case this issue is not resolved after re-creating yarn.lock.

Unless they are listed as peerDependencies there is no expectation that they would be resolved to the same dependency. That's the "ideal" case but not a given, so this behavior is not a bug.

@BYK thank you for the information! I think that I can close this issue now. But maybe we need to document this somewhere? What do you think about it? I am not sure, but it can confuse someone else.

@vkrol maybe we can create an FAQ page for this since it has been brought up so many times recently.

@BYK I agree. This will be very helpful. Do we need to create the separate issue for it?

@vkrol yup. I'd create an issue in the website repo and ping @arcanis about it. We may also try adding a check about possible duplicates in the tree and show people an info message about this.

Was this page helpful?
0 / 5 - 0 ratings