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
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With