Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When installing packages with Yarn, what does "incorrect peer dependency" mean?

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 "[email protected]" 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?

like image 361
shrewdbeans Avatar asked Feb 21 '17 08:02

shrewdbeans


People also ask

What is yarn Peer dependency?

Having a peer dependency means that your package needs a dependency that is the same exact dependency as the person installing your package. This is useful for packages like react that need to have a single copy of react-dom that is also used by the person installing it.

How do you install peer dependencies in yarn?

Run npm install (or yarn install ) to install prod and dev , as well as peer dependencies. You still may see "unmet peer dependency" warnings, due to installation flow of npm/yarn. Also it won't update lock (shrinkwrap) files or modify package. json, keeping your setup pure and clean.

How do you resolve peer dependencies?

Solution 1: Ignore the peerDependencies The easiest way to fix the issue is to pass an additional parameter –legacy-peer-deps to npm install. The --legacy-peer-deps tells the npm to ignore the peer dependencies and continue the installation of the package.

How do you fix unmet dependencies in yarn?

Running yarn install --check-files or just yarn install can fix the issue and install the missing depecendencies. Explicitly adding to your package. json may also be an option.


1 Answers

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

like image 56
JonnyFoley Avatar answered Sep 21 '22 14:09

JonnyFoley