Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

yarn warning package has unmet react peer dependency

I am getting a whole heap of unmet peer-dependency warnings when doing a fresh install with yarn.

I own one of the dependencies (lets call it my-problematic-package) and have set the peerDependency as follows:

"peerDependencies": {
  "react": "0.14.x - 16.x.x",
  "react-dom": "0.14.x - 16.x.x"
}

I am then including the package in my project with the following defined for dependencies:

"dependencies": {
  ...
  "react: "^16.0.0",
  "my-problematic-package": "^1.1.0" // Latest with react as devDependency
}

I then get the following when running yarn:

warning > [email protected]" has unmet peer dependency "[email protected] - 16.x.x".

Seems legit but not working, any suggestions welcome.

Yarn version: 1.3.2

NPM version: 5.5.1

like image 427
nickspiel Avatar asked Jan 17 '18 09:01

nickspiel


People also ask

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.

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.

What is unmet Peer dependency?

UNMET PEER DEPENDENCY error is thrown when the dependencies of one or more modules specified in the package. json file is not met. Check the warnings carefully and update the package. json file with correct versions of dependencies.

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.


1 Answers

Okay, so it turns out it was not my problem. Yarn v 1.3.2 has a bug when warning on peerDependencies.

1.4.0 shipped as a release candidate a couple of days ago and I no longer see these incorrect warnings in this release.

Links: Related issue: https://github.com/yarnpkg/yarn/issues/4743 PR: https://github.com/yarnpkg/yarn/pull/5088

like image 131
nickspiel Avatar answered Oct 14 '22 21:10

nickspiel