Skip to main content

How does pnpm save disk space?

pnpm saves disk space through a centralized cache and hard links, instead of copying the same packages into every project.


The saving mechanism

  1. A single package store
  • pnpm stores downloaded dependencies in one global cache (usually in ~/.pnpm-store).
  • If another project needs the same package version, pnpm does not download it again.
  1. Hard links instead of copies
  • In node_modules, pnpm does not copy files, it creates hard links to the cache.
  • As a result, the disk effectively holds one copy of each dependency, even if it is used across dozens of projects.

The difference from npm/Yarn

ManagerWhere packages liveResult
npm / Yarna package copy in every projectgigabytes of duplicates
pnpm1 copy in the cache + linksminimal disk space

The practical effect

  • the same React, lodash, moment, and so on are not stored hundreds of times;
  • the savings can add up to dozens of gigabytes across many projects;
  • installation gets faster because there are no repeat downloads or copies.

Conclusion

pnpm saves space through a global cache and hard links in node_modules, which eliminates dependency duplication and sharply cuts the disk space packages take up.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.