What are those PeerDependencies in a NodeJS project?

Manuel Penaloza on November 30, 2018

PeerDependencies, one of the terms that brought up confusion at least to me when I got a PeerDependency warning in my terminal like the following... [Read Full]
markdown guide
 

Nice article. I got several questions about it.

  1. the solution for the error in the screenshot is the maintainer of react-redux package should declare a peerDependency of react@0.14.0 in its package.json. am I right?
  2. My second question is why they let this error happen. why do you let the jacksFunciton take an jillsObject of version2 instead of the version 1 that it needs? I assume the person who call jacksFunction already know the exact version it needs.
 

Hey!
Thx for your questions.

  1. what you've described, is what the maintainer of the react-redux package has already done, see here github.com/reduxjs/react-redux/blo.... That's the reason why the warning is thrown here. The solution to this warning is, that the developer of that project (that uses react-redux) has to add react@0.14.0 on its own as a project dependency.

  2. "... I assume the person who call jacksFunction already know the exact version it needs." > the person who calls jacksFunction might not necessarily know this when installing and initially using the npm package jacksmodule. The definition of a peer dependency in jacksmodule's package.json will throw the helping hint that the person should install the proper version of jillsModule.

Hope that helped to answer your questions (?).

 
 

I specially signed in to write a comment for this article. Really thank you, man. It's already 2 months I can't really understand and even find a good article related to peerDependencies. One small thing I couldn't understand from StackOverflow answer and from this article is it.

From StackOverflow -
How peer dependencies solve this.
They tell npm
I need this package, but I need the version that is part of the project,
not some version private to my module.

From this article -
"Hey, this is JacksModule speaking here. Let me tell you: I need this
specific package of JillsModule, but I really need the version that is
part of my JacksModule project and listed in my package.json file. So
please make sure it's installed and make sure it's not some other version
of JillsModule you might have installed for your own usage somewhere else
in your application."

Note the difference. You say that I need this
specific package of JillsModule, but I really need the version that is
part of my JacksModule project and listed in my package.json file.
and StackOverflow says I need this package, but I need the version that is part of the project,
not some version private to my module.

Could you please explain it ?

 
 

Finally found an explanation that makes me feel confortable, thanks

 
 
 

No online resource was clear enough for me to understand peerDependencies except this one. Great Article!

 
 

Thank you, great overview, it certainly helped clarify things for me. Keep up the great work! :)

 
 

What the point to just repeat someone others explanation from stackoverflow

 

"In this blog post I'll write down what I found out about NodeJS PeerDependencies IN A WAY THAT ALSO MIGHT HELP YOU to better understand this topic."
...
"But somehow and as I am more a visual learning type Stijn's "text-driven" Stackoverflow explanation did not bring up that imaginary last-mile satisfaction for me in terms of understanding PeerDependencies. As a result I DRAW SOME CODE AROUND HIS EXPLANATION (you can see quoted below) and suddenly things became more clear to me."

does that answer your question?

 
code of conduct - report abuse