Yarn Plug'n'Play vs Classic node_modules: Disk‑size vs Tooling Compatibility
0 reputation · 16 Oct 2023, 07:07 UTC
The goal is to minimize storage overhead for a low‑traffic service by selecting either Yarn Plug'n'Play or the classic node_modules installation method.
Plug'n'Play stores packages in a centralized .yarn folder and uses a pnp‑lock.yaml lockfile, which cuts the container image size but requires a custom resolver that may not reproduce every npm package behavior, potentially affecting scripts or tools that rely on the node_modules layout.
The classic approach keeps a local node_modules directory, guaranteeing compatibility with existing tooling but increasing disk usage and prolonging image pulls, while the lockfile remains yarn.lock, preserving deterministic installs without the storage savings of Plug'n'Play.
Does the storage reduction from Plug'n'Play outweigh the risk of resolver incompatibility for low‑traffic workloads? Can teams adopt Plug'n'Play without updating tooling that expects a node_modules folder?