1

Does having incorrect/unmet peer dependencies have any significant impact on my react project. I have read the yarn official documentation and it says:

Peer dependencies are a special type of dependency that would only ever come up if you were publishing your own package.

I am not publishing any package here, just a simple react project with installed dependencies. I don't know why it is the case with my react application but I am getting this warning each time I hit yarn install

[3/4] Linking dependencies...
warning "@react-pdf/renderer > react-reconciler@0.24.0" has incorrect peer dependency "react@^16.0.0".
warning " > @testing-library/user-event@12.8.3" has unmet peer dependency "@testing-library/dom@>=7.21.4".
warning "aws-amplify > @aws-amplify/analytics > @aws-sdk/client-firehose > @aws-sdk/middleware-retry > react-native-get-random-values@1.8.0" has unmet peer dependency "react-native@>=0.56".
warning " > mobx-devtools-mst@0.9.30" has incorrect peer dependency "mobx@^2.2.0 || ^3.0.0 || ^4.0.0 || ^5.0.0".

Should I take it seriously and add the peer dependencies properly, and If I choose not to do so, does this negatively impact my project? Can they be automatically added? and why yarn does not automatically add them at the time of adding a dependency?

devenv: Using yarn v1.22.18 as my package manager with node:16-buster image.

Dinkar Jain
  • 610
  • 5
  • 13
  • Does this answer your question? [When installing packages with Yarn, what does "incorrect peer dependency" mean?](https://stackoverflow.com/questions/42361942/when-installing-packages-with-yarn-what-does-incorrect-peer-dependency-mean) – SMAKSS Jun 02 '22 at 00:26
  • Answers there don't explain it well, there is no debate over its negative impact, where is it not ignorable, and why yarn doesn't install those dependencies if it cares to warn about them. – Dinkar Jain Jun 02 '22 at 04:03

2 Answers2

1

There can only be a single package "A" installed into node_modules. If you have two packages "B" and "C"

  • "B" needs "A@1.0.0"
  • "C" needs "A@2.0.0"

In this hypothetical situation assume that "A" removed a function that "B" was using in 2.0.0. When you code is running, you will get a bizarre error that function was not found or undefined.

This is the problem that can arise with mismatched peer dependencies. You get bizarre errors or behaviors that when you look at the stacktrace, your code is not actually involved in.

In many situations, you don't use 100% of the code in all packages, and your packages don't use all of the code in their dependency, but when it does come up, it is a serious pain to fix.

yxre
  • 3,576
  • 21
  • 20
  • That's one of the problems. Recently came across a blog post, they were talking about the same problem as mentioned above > https://zerodha.tech/blog/from-native-to-react-native-to-flutter/#:~:text=it%20often%20came,or%20a%20lib. – Dinkar Jain Jun 03 '22 at 06:49
-2

Peer Dependencies:-

Let Package X need package Y Version 2.0 to work correctly but you installed package Y Version 1.0 then it will give you a warning you don't need to worry about it if it is just a warning when you upload the source code to the server you will reinstall the packages again on it so packages manager will handle it.

iiFire
  • 1
  • 2