110

I've just cloned a repo, which recommends the use of Yarn to install dependencies. When I run yarn install, it seems to be okay, but it provides this warning:

yarn install v0.20.3
[1/4]   Resolving packages...
[2/4]   Fetching packages...
[3/4]   Linking dependencies...
warning "sass-loader@4.0.2" has incorrect peer dependency "node-sass@^3.4.2".
[4/4]   Building fresh packages...
✨  Done in 77.59s.

I've looked online to find out exactly what "has incorrect peer dependency" means. But all I can find are reported issues on other repositories or questions about how to fix the problem.

Can someone explain what this means and why it is only a warning, and not an error?

Also, is it something that I should try to address or report to the community behind the repo I have just cloned?

Nikita Fedyashev
  • 16,963
  • 11
  • 45
  • 76
shrewdbeans
  • 11,061
  • 22
  • 65
  • 109
  • Potential duplicate: https://stackoverflow.com/questions/46928390/what-does-has-unmet-peer-dependency-mean-when-installing-a-package-with-yarn – Kalinda Pride Jun 16 '21 at 01:00

2 Answers2

39

It is only a warning as it won't actually stop your code from running, It's just there to give you a heads up that there's something wrong with your dependencies.

Effectively, peer dependencies are a way for packages to specify, "to use me, you should also have x version of y package installed".

You should upgrade to the latest versions, see this link for more details on sass-loader dependencies

J Foley
  • 865
  • 1
  • 14
  • 28
7

I think that there are packages for which it doesn't make a big difference (if not exposed in your app or not likely that conflicting versions create problems, e.g. moment.js), but then there are packages, like React, for which it matters that all React dependencies are compatible with each other as they might create components that have to understand each other.

In your case, probably one of your dependencies uses sass-loader in a different version than you specify in your project.

By declaring it as a peerDependency you can tell npm which version your project expects and it will give you a warning (as you saw) when there is a conflict.

Lee
  • 559
  • 5
  • 14
Flip
  • 5,443
  • 6
  • 39
  • 69
  • I was wondering whether it's saying the information in the packages package.json has a wrong dependency listed That's where it gets it's information from isn't it? Just from reading package.json files It's not concerning about what node_modules are installed that aren't included in package.json – Mices May 04 '21 at 02:30