[SOLVED] What does ‘has unmet peer dependency’ mean when installing a package with yarn?


This Content is from Stack Overflow. Question asked by Giorgi Moniava

There is similar question but as the comments mention (e.g. comment by Akhila), the accepted answer seems to be about npm. I am using yarn.
I upgraded to React 18, a create react app project and noticed these:

warning “react-scripts > eslint-config-react-app >
eslint-plugin-flowtype@8.0.3” has unmet peer dependency

warning “react-scripts >
react-dev-utils > fork-ts-checker-webpack-plugin@6.5.0” has unmet peer
dependency “typescript@>= 2.7”.

So is my understanding correct I should manually add these as dependencies to my project?


What is a peer dependency

Here is some useful reading on dependency types, and here is info on peer dependencies, but to summarize:

Dependency: A library/package your project needs to run.
Peer dependency: Used to indicate a library/package your project will hook in to.

The package vue-loader has a peer dependency on vue-template-compilervue-loader acts as a plugin for vue-template-compiler

Why aren’t peer dependencies installed by default

Peer dependencies were automatically installed up until npm@3 (which yarn has followed in). This was stopped due to frequently confusing behavior. For example, installing another plugin with a conflicting requirement would result in an error.

We will also be changing the behavior of peerDependencies in npm@3. We won’t be automatically downloading the peer dependency anymore. Instead, we’ll warn you if the peer dependency isn’t already installed. This requires you to resolve peerDependency conflicts yourself, manually, but in the long run this should make it less likely that you’ll end up in a tricky spot with your packages’ dependencies. [Feb 13, 2015]


As per here npm@7 now installs peer dependencies.
For the motivation behind this decision see here

This Question was asked in StackOverflow by WoJ and Answered by Leighton It is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?