Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between unmet and incorrect peer dependency?

Tags:

npm

yarnpkg

I believe I understand what "unmet peer dependency" means. For example "package-a" depends on "package-b@^2.1.5" but no version of [email protected] (>=2.1.5) is installed.

But "incorrect dependency" baffles me. It would make no sense to say "package-a is asking for an incorrect dependency". Is it saying that the dependency listed in package-lock.json or yarn.lock doesn't match what package-a says it needs? If this is correct, then how would this be resolved?

When I search for specific discussion about "incorrect dependency" on Github, it seems to show up on issues in the yarn or npm repos. And the resolution usually seems to be a fix to yarn or npm. Is this message for bugs in yarn/npm?

If I search https://docs.npmjs.com/ for "incorrect peer dependency", I get no results.

like image 408
John Pankowicz Avatar asked May 25 '18 20:05

John Pankowicz


People also ask

What is an 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.

What is peer dependency?

A peer dependency specifies that our package is compatible with a particular version of an npm package. If a package doesn't already exist in the node_modules directory, then it is automatically added. As you install a package, npm will automatically install the dev dependencies.

How do you install unmet Peer dependency yarn?

Usage. 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.


1 Answers

  • Unmet peer dependency means the dependency has not been installed at all.
  • Incorrect peer dependency means it has been installed, but in the wrong version.

Given these package.json

{
  name: "app"
  dependencies: {
    "package-a": "*"
  }
}

{
  name: "package-a",
  peerDependencies: {
    "package-b": "^2.1.5"
  }
}

A yarn install will give you an unmet peer dependency, since app does not make sure package-b gets installed.

If you add it as a dependency, but in a wrong version

{
  name: "app"
  dependencies: {
    "package-a": "*",
    "package-b": "~2.0.0"
  }
}

you will get an incorrect peer dependency.

like image 163
Andy Avatar answered Oct 22 '22 01:10

Andy