One of the best features of pnpm is that in one project, a specific version of a package will always have one set of dependencies. There is one exception from this rule, though - packages with peer dependencies.
Peer dependencies are resolved from dependencies installed higher in the
dependency graph, since they share the same version as their parent. That means
firstname.lastname@example.org has two peers (
baz@^1) then it might have
multiple different sets of dependencies in the same project.
In the example above,
email@example.com is installed for
foo-parent-2. Both packages have
bazas well, but they depend on
different versions of
baz. As a result,
firstname.lastname@example.org has two different sets of
dependencies: one with
email@example.com and the other one with
support these use cases, pnpm has to hard link
firstname.lastname@example.org as many times as
there are different dependency sets.
Normally, if a package does not have peer dependencies, it is hard linked to a
node_modules folder next to symlinks of its dependencies, like so:
foo has peer dependencies, there may be multiple sets of
dependencies for it, so we create different sets for different peer dependency
We create symlinks either to the
foo that is inside
email@example.com_bar@firstname.lastname@example.org or to the one in
As a consequence, the Node.js module resolver will find the correct peers.
If a package has no peer dependencies but has dependencies with peers that are
resolved higher in the graph, then that transitive package can appear in the
project with different sets of dependencies. For instance, there's package
email@example.com with a single dependency
firstname.lastname@example.org has a peer dependency
email@example.com will never resolve the peers of
firstname.lastname@example.org, so it becomes
dependent from the peers of
email@example.com as well.
Here's how that structure will look in
node_modules. In this example,
firstname.lastname@example.org will need to appear twice in the project's
node_modules - resolved
email@example.com and again with