Skip to content

Node.js linkers

Yarn supports three different ways to install your projects on disk. This document gives a quick overview of each of them, along with the pros and cons of each.

nodeLinker: pnp

For more details about Plug’n’Play installs, check the dedicated section.

Under this mode Yarn will generate a single Node.js loader file directory referencing your packages from their cache location. No need for file copies, or even symlinks / hardlinks.

ProsCons
Extremely fastLess idiomatic
Content-addressable storeIDE integrations often require SDKs
Protects against ghost dependenciesSometimes requires packageExtensions
Semantic dependency errors
Perfect hoisting optimizations
Provides a dependency tree API
Can be upgraded into zero-installs

nodeLinker: pnpm

Section titled “”

Under this mode, a flat folder is generated in node_modules/.pnpm containing one folder for each dependency in the project. Each dependency folder is populated with hardlinks obtained from a central store common to all projects on the system (by default $HOME/.yarn/berry/index). Finally, symlinks to the relevant folders from the flat store are placed into the node_modules folders.

ProsCons
Slower than PnP, but still very fastSymlinks aren’t always supported by tools
Content-addressable storeHard links can lead to strange behaviors
Protects against some ghost dependenciesGeneric dependency errors
No need for IDE SDKsSometimes requires packageExtensions

nodeLinker: node-modules

Section titled “”

This mode is the old tried and true way to install Node.js projects, supported natively by Node.js and virtually the entirety of the JavaScript ecosystem.

While we tend to recommend trying one of the two other modes first, it remains a solid option in case you face problems with your dependencies that you don’t have the time to address right now. Sure, your project may be a little more unstable as you won’t notice if ghost dependencies creep in, but it may be a reasonable trade-off depending on the circumstances.

ProsCons
Perfect compatibility with the whole ecosystemAverage speed
Optional support for hardlinks (nmMode)No protection against ghost dependencies
No need for IDE SDKsImperfect hoisting due to the filesystem reliance