Table of Contents

About

Peer Dependencies is a dependency relationship indicating that the dependencies should be provided by parent in the dependency tree.

They are provided by the parent. ie

  • a framework (Jquery, …)
  • the HTML page
  • the root of a monorepo

It indicates that:

  • your (module|package) cannot be used without this dependency.
  • the parent dependency should provide this dependency
  • the dependency will not be available in the distributed artifact.

Example

They model a parent-child relationship

  • Plugin (for the parent, for instance, the jQuery framework)
  • Workspace (for the root parent of the mono repo)
  • Page (where the page provide the peer dependencies)

Management

Javascript

In Javascript Package - Package.json, they are declared in the peerDependencies property of the package.json file.

  • You can add them also at the command line with your package manager. Example: yarn:
yarn add [package] --peer

Bundler - You may have to change the configuration of your bundler to exclude them. Example webpack