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

Unmet peer dependency #5514

Closed
billybonks opened this issue Mar 13, 2018 · 6 comments
Closed

Unmet peer dependency #5514

billybonks opened this issue Mar 13, 2018 · 6 comments
Assignees
Labels

Comments

@billybonks
Copy link

Bug
It seems like a bug, but if you know why it gives this error and is not a bug would love an explanation :). if it is a bug would be happy to help out and fix it.

What is the current behavior?
image

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

git clone git@github.com:billybonks/yarntest.git
yarn install

What is the expected behavior?
Does not give a warning about missing dependencies

Please mention your node.js, yarn and operating system version.
node v8.0.0 / macOS10.13.3

@ghost ghost assigned rally25rs Mar 13, 2018
@ghost ghost added the triaged label Mar 13, 2018
@rally25rs
Copy link
Contributor

You have a dependency on stylelint-config-standard.

stylelint-config-standard lists a peerDependency on stylelint. See:
https://github.com/stylelint/stylelint-config-standard/blob/master/package.json#L35

Back in npm v3 (i think? somewhere around there...) npm stopped automatically installing peerDependencies and started just warning about them being missing. Therefore yarn exhibits this same behavior.

You get the warning because no package that is a parent of stylelint-config-standard is installing stylelint.

In this case your project is the only parent to stylelint-config-standard so your project should include stylelint as a dependency on its own.

So running:

yarn add stylelint

should fix your issue.

There is a longer writeup of how peerDeps work on the node blog: https://nodejs.org/en/blog/npm/peer-dependencies/

Hope that makes sense! (going to close this issue since this hopefully answers your question, but if you have additional questions, don't hesitate to ask.)

@billybonks
Copy link
Author

billybonks commented Mar 16, 2018

@rally25rs thanks so much for that information :), i was stepping through the code and your explanation makes what i saw in the code make much more sense :).

@billybonks
Copy link
Author

billybonks commented Mar 16, 2018

@rally25rs i did more investigation into the difference in npm v5.x vs yarn.

it seems that in npm 5 if a sibling dependency includes a package defined in the peerDependencies of the other sibling it won't show the error.

if no sibling package or parent package includes the target dependency it will show the error

//no error

git clone git@github.com:billybonks/yarntest.git
cd yarntest
npm install

//shows error

git clone git@github.com:billybonks/yarntest.git
cd yarntest
git checkout without-stylelint
npm install

i can't find any docs that explain the behaviour but i think if the dependency is installed at the first depth of the tree it won't show the warning.

what are your thoughts on the difference of behaviour. i tested using npm v5.7.1

@rally25rs
Copy link
Contributor

rally25rs commented Mar 17, 2018

That feels like an npm bug to me. If you think of it as a dependency tree:

|- stylelint-config-standard
|- broccoli-stylelint
    |- stylelint

If node_modules was actually organized in that way (no hoisting) then node.js would not be able to resolve stylelint for stylelint-config-standard, because it isn't located in a parent directory.

Now in reality, it actually does resolve at runtime, only because nom and yarn both will "hoist" the packages to a flat dir structure:

|- stylelint-config-standard
|- broccoli-stylelint
|- stylelint

but that feels like more of a side-effect of the hoisting, rather than really satisfying the peerDependency.

On the plus side, it's just a warning and not an error, so you can safely ignore it in this case.

@rally25rs
Copy link
Contributor

found a duplicate: #4675

@billybonks
Copy link
Author

thanks, ill continue discussion on that thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants