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
- 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.
- 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
| Manager | Where packages live | Result |
|---|---|---|
| npm / Yarn | a package copy in every project | gigabytes of duplicates |
| pnpm | 1 copy in the cache + links | minimal 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 readyPremium
A concise answer to help you respond confidently on this topic during an interview.