yarn seems to be erroneously logging incorrect peer dependency warnings

Created on 13 Sep 2017  ยท  13Comments  ยท  Source: yarnpkg/yarn

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

Bug Report

What is the current behavior?

__tl;dr yarn seems to be erroneously logging incorrect peer dependency warnings even though the dependencies install correctly as one would expect given the package.json files.__

We have a monorepo structure with lerna using independent versioning and yarn workspaces. When we run yarn or yarn install we are seeing multiple incorrect peer dependency warnings.

We have multiple npm packages in the monorepo and some of the packages have 1 way dependencies amongst themselves.

For example:

  • package-B has a dependency / peerDependency on package-A ^1.0.0
  • package-C has a dependency / peerDependency on package-A ^1.0.0

package-B and package-C have dependencies and peerDependencies which look like this:

"peerDependencies": {
    "package-A": "^1.0.0",
  },
  "dependencies": {
    "package-A": "^1.0.0",
  },

Even though there are multiple incorrect peer dependency warnings, the dependencies are installed as expected in the root node_modules directory which satisfies the specified dependencies and peerDependencies for each package.

If the current behavior is a bug, please provide the steps to reproduce.
I'm trying to create a reduced test-case, but you can reproduce the warnings in our project repo, terra-core, in this branch: https://github.com/cerner/terra-core/tree/update-lerna

Steps to repro:

  • Clone repo: git clone https://github.com/cerner/terra-core.git
  • Checkout the update-lerna branch: git fetch origin git checkout --track origin/update-lerna
  • Run yarn to install deps: yarn

Once it gets to the Linking dependencies... step, it will start to log multiple warnings around incorrect peer dependencies.

Here is the output related to the warnings:


Output

yarn install v1.0.1
[1/5] ๐Ÿ” Validating package.json...
[2/5] ๐Ÿ” Resolving packages...
[3/5] ๐Ÿšš Fetching packages...
[4/5] ๐Ÿ”— Linking dependencies...
warning "[email protected]" has incorrect peer dependency "ajv@>=4.10.0".
warning "[email protected]" has incorrect peer dependency "postcss@^6.0.0".
warning "[email protected]" has incorrect peer dependency "webpack@2 || 3".
warning "[email protected]" has incorrect peer dependency "webpack@^2.2.0".
warning "[email protected]" has incorrect peer dependency "webpack@1 || ^2 || ^2.1.0-beta || ^2.2.0-rc || ^3".
warning "[email protected]" has incorrect peer dependency "node-sass@^4.0.0".
warning "[email protected]" has incorrect peer dependency "webpack@^2.0.0 || >= 3.0.0-rc.0 || ^3.0.0".
warning "[email protected]" has incorrect peer dependency "webpack@^2.2.0 || ^3.0.0".
warning "[email protected]" has incorrect peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-button@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-icon@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-responsive-element@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-mixins@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-button@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-mixins@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-button@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-form@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-icon@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-responsive-element@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "xfc@^1.0.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-icon@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-arrange@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-content-container@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-icon@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-list@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-popup@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-slide-group@^1.8.0".
warning "[email protected]" has incorrect peer dependency "react-redux@^5.0.4".
warning "[email protected]" has incorrect peer dependency "redux@^3.6.0".
warning "[email protected]" has incorrect peer dependency "terra-app-delegate@^1.4.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-icon@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-icon@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-image@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-button@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-form@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-icon@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-icon@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-mixins@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-form@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-arrange@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "terra-button@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-icon@^1.9.0".
warning "[email protected]" has incorrect peer dependency "terra-toggle@^1.8.0".
warning "[email protected]" has incorrect peer dependency "terra-base@^2.3.0".
warning "[email protected]" has incorrect peer dependency "prop-types@^15.5.4".
warning "[email protected]" has incorrect peer dependency "redux@^2.0.0 || ^3.0.0".



What is the expected behavior?
Running through the steps to reproduce the bug does not trigger erroneous incorrect peer dependency warnings.

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

| Software | Version |
|---|---|
| Node.js | 8.4.0 |
| yarn | 1.0.1 |
| OS | OS X El Capitan v10.11.6 |

Additional Notes
I spent some time looking through the Yarn codebase to see if I could better understand this issue. I ended up here but wasn't able to spot anything around what causes this issue.

Related issues
https://github.com/yarnpkg/yarn/issues/4342
https://github.com/yarnpkg/yarn/issues/4064
https://github.com/yarnpkg/yarn/issues/2387
This may have some relation with this issue as well: https://github.com/yarnpkg/yarn/issues/4432

triaged

Most helpful comment

I'm still seeing something similar:

warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/camera@^3.0.0".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/net@^3.1.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/renderer@^8.3.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/utils@^0.28.2".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "[email protected]".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "react@^16.2.0".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "react-transition-group@^2.2.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "redux@^3.7.2".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "rxjs@^5.5.6".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/net@^3.1.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/renderer@^8.3.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "file-saver@^1.3.3".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "rxjs@^5.5.6".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common > [email protected]" has unmet peer dependency "[email protected]".

It seems to happen for peer deps that are required by workspaces, even though they are eventually deps in other workspaces:

// workspaces/w1/package.json
{
    "name": "w1",
    "dependencies": {
        "package-a": "^1.0.0",
        "package-b": "^2.0.0"
    }
}

// workspaces/w2/package.json
{
    "name": "w2",
    "peerDependencies": {
        "package-a": "^1.0.0"
    }
}

// root package.json
{
    "name": "",
    "dependencies": {}
}

Running yarn install at root would complain that package-a has unmet peer dep.

All 13 comments

@bjankord thanks for tidying up those issues. These all look stemming from the same root cause to me so may be we should consolidate all of them into a single issue (may be this one?). What do you think?

+1, sounds good to me.

It seems to be caused by changes in https://github.com/yarnpkg/yarn/pull/3803.

Easy repro is to clone Yarn repo and $ yarn install it :)
It produces warning "[email protected]" has incorrect peer dependency "ajv@>=4.10.0". using 1.0.2.

$ yarn why ajv-keywords
yarn why v1.0.2
[1/4] ๐Ÿค”  Why do we have the module "ajv-keywords"...?
[2/4] ๐Ÿšš  Initialising dependency graph...
[3/4] ๐Ÿ”  Finding dependency...
[4/4] ๐Ÿšก  Calculating file sizes...
info Reasons this module exists
   - "eslint#table" depends on it
   - "webpack" depends on it
$ yarn list ajv-keywords ajv table eslint webpack
yarn list v1.0.2
โ”œโ”€ [email protected] has peer on "ajv": ">=4.10.0"
โ”œโ”€ [email protected] satisfies peer
โ”œโ”€ [email protected]
โ”‚  โ””โ”€ [email protected]
โ”œโ”€ [email protected] has "ajv": "^4.7.0" and "ajv-keywords": "^1.0.0" in dependencies
โ””โ”€ [email protected] has ajv": "^4.7.0" and "ajv-keywords": "^1.1.1" in dependencies

From the linked PR it looks like one should satisfy every peer dependency in the root package.json even if it was already satisfied lower in the dependency chain. At least I can fix warning in Yarn repo by doing:

$ yarn add [email protected]

Is "one should satisfy every peer dependency in the root package.json even if it was already satisfied lower in the dependency chain" really the intended behavior?

Maybe I don't understand all the implications, but I don't see any sense in the warning for the given dependency tree. Since table and webpack already satisfied peerDependencies of ajv-keywords why one should have to add it in the root package.json. And if table and webpack want to ensure that package, who depends on them, will get single instance of ajv-keywords they should have it in their own peerDependencies. No?

cc @kaylieEB

Definitely seems like the same issue as https://github.com/yarnpkg/yarn/issues/4342. The PR (https://github.com/yarnpkg/yarn/pull/3803) was to fix incorrect semver modules from being copied in nested modules structure, but we can revert it for now since we have selective resolutions to force a nested module to have a particular version. This would restore the old bug (https://github.com/yarnpkg/yarn/issues/3710) by swallowing the warning but at least there's a workaround. @BYK I can't work on the real fix atm, maybe next week or so -- what do you think?

fyi, I think https://github.com/yarnpkg/yarn/issues/2387 is a separate issue.

Has this been released yet?

@elsurudo yup: 1.1.0

Thanks for the quick fix on this!

It looks like this mostly fixed the issue for me. But I'm running into a case with beta version numbers that still logs peer dependency errors in workspace mode:

warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > [email protected]" has unmet peer dependency "@babel/core@^7.0.0-0".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > [email protected]" has unmet peer dependency "@babel/core@7 || ^7.0.0-beta || ^7.0.0-rc".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > @babel/preset-react > @babel/[email protected]" has unmet peer dependency "@babel/[email protected]".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > @babel/preset-react > @babel/[email protected]" has unmet peer dependency "@babel/[email protected]".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > @babel/preset-react > @babel/[email protected]" has unmet peer dependency "@babel/[email protected]".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > @babel/preset-react > @babel/[email protected]" has unmet peer dependency "@babel/[email protected]".
warning "workspace-aggregator-1a6f09e5-756e-46d3-b91e-d2f8fdf04e82 > mypackagename > @babel/preset-react > @babel/[email protected]" has unmet peer dependency "@babel/[email protected]".

This only happens when a beta package is not listed in every work space package. For example, I use @babel/preset-react only in one of my packages, but use @babel/preset-typescript in all of them. The error is only logged for the former but not the latter.

If I add "@babel/core": "7.0.0-beta.36" to the root package.json file the warnings go away. This dependency is listed in every package.json file though...

Still getting warnings with yarn v 1.3.2

warning "@storybook/react > @storybook/ui > react-icons > [email protected]" has unmet peer dependency "prop-types@*".
warning " > [email protected]" has unmet peer dependency "prop-types@^15.6.0".

package installed

"prop-types": "^15.6.0"

I'm still seeing something similar:

warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/camera@^3.0.0".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/net@^3.1.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/renderer@^8.3.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/utils@^0.28.2".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "[email protected]".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "react@^16.2.0".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "react-transition-group@^2.2.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "redux@^3.7.2".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "rxjs@^5.5.6".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/net@^3.1.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "@bbpviz/renderer@^8.3.1".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "file-saver@^1.3.3".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/[email protected]" has unmet peer dependency "rxjs@^5.5.6".
warning "workspace-aggregator-204c990a-5736-4c41-a992-1a77766417cc > @sauron/common > [email protected]" has unmet peer dependency "[email protected]".

It seems to happen for peer deps that are required by workspaces, even though they are eventually deps in other workspaces:

// workspaces/w1/package.json
{
    "name": "w1",
    "dependencies": {
        "package-a": "^1.0.0",
        "package-b": "^2.0.0"
    }
}

// workspaces/w2/package.json
{
    "name": "w2",
    "peerDependencies": {
        "package-a": "^1.0.0"
    }
}

// root package.json
{
    "name": "",
    "dependencies": {}
}

Running yarn install at root would complain that package-a has unmet peer dep.

Getting same behaviour for namespaced packages...

I still see the same with yarn 1.15.2 for yarn global add relaxedjs.

Can we reopen this?

Just experienced this. The warning I get:

warning " > [email protected]" has unmet peer dependency "vue@>= 1.0.0".

Though [email protected] is included as a dependency of @quasar/[email protected].

Yarn version is 1.16.0 on macOS 10.14.4, using nodejs v10.15.3.

Was this page helpful?
0 / 5 - 0 ratings