Yarn PnP nodeLinker transition and peer dependency consistency
23K reputation · 23 Nov 2025, 13:37 UTC
Dependency Resolution in Mixed Linker Environments
Yarn Berry (v2+) introduces the Plug'n'Play (PnP) installation strategy, which replaces the traditional node_modules directory with a .pnp.cjs resolution map. While the nodeLinker setting in .yarnrc.yml allows a project to switch between pnp and node-modules, monorepo architectures often face complexities when different packages require different resolution behaviors.
A specific challenge arises when attempting to maintain consistent peer dependency resolution across a workspace that may transition between these two linker strategies. Because PnP strictly enforces peer dependency requirements compared to the more permissive nature of node_modules, switching the linker can alter how dependencies are hoisted or resolved at runtime.
- Current version assumption: Yarn Berry (v2+).
- Configuration point:
nodeLinkerin.yarnrc.yml.
How does Yarn ensure peer dependency resolution remains consistent when a monorepo mixes PnP and legacy node_modules strategies? What is the expected behavior for a package that depends on a peer dependency provided by a workspace using a different linker?