pnpm, npm and Yarn caches on a Mac, measured on the same three projects: 154 MB to 1,017 MB
We installed the same three projects (an Express API, a React and Vite app, and an ESLint, Prettier and Vitest toolbox) with npm 10.9.9, pnpm 12.21.0, Yarn 1.22.22 and Yarn 4.19.0 on one Mac, each with its own empty cache. The <code>node_modules</code> folders came out within 12% of each other, 146 to 164 MB. The cache each manager keeps was another story: 154 MB for Yarn 4, 236 MB for npm, 236 MB by <code>du</code> for pnpm (about half of it real), and <strong>1,017 MB for Yarn 1</strong>. Here are the numbers, the reason behind the biggest one, what pnpm's “hard links” really are on a Mac, and what each prune command freed.
What we measured
- Apple M4 Mac mini, macOS 27.2.1, Node 22.23.4, 22 November 2026. Every manager ran with a scratch
HOMEand its own cache or store folder under/tmp, so nothing touched the real caches. - npm 10.9.9, pnpm 12.21.0, Yarn 1.22.22 and Yarn 4.19.0 (
nodeLinker: node-modules, global cache on), installed from the registry with no lockfile. The threepackage.jsonfiles pinned only the top-level versions. - api: express 5.1.0, zod 4.1.5, axios 1.12.2, dotenv 17.2.2. web: react and react-dom 19.1.1, vite 7.1.5, @vitejs/plugin-react 5.0.2, typescript 5.9.2. lint: eslint 9.35.0, prettier 3.6.2, typescript 5.9.2, vitest 3.2.4. TypeScript is in two projects on purpose, to see which managers share it.
- Sizes are
du -sk(allocated space), shown as MB of 1,048,576 bytes. Each project was installed in turn into the same cache, so the cache columns are cumulative. One run per manager; install seconds depend on the network and are only a hint.
The same installs, four caches
| Manager | node_modules, 3 projects (MB) | Cache or store after 3 installs (MB) | Files in the cache | Cold install seconds (api / web / lint) | Reinstall of web with the cache (s) |
|---|---|---|---|---|---|
| npm 10.9.9 | 148.9 | 235.7 | 1,190 | 8 / 89 / 64 | 1 |
| pnpm 12.21.0 | 145.7 | 236.4 (du) | 10,773 | 5 / 39 / 19 | 0 |
| Yarn 1.22.22 | 157.6 | 1,017.3 | 6,492 | 5 / 189 / 174 | 1 |
| Yarn 4.19.0 | 163.5 | 153.7 | 609 | 4 / 76 / 29 | 0 |
The reinstall column is <code>node_modules</code> deleted and installed again with the cache and a lockfile in place; every manager did it in a second or less. That speed is what the cache buys. The next table shows what it costs as it grows project by project.
| Cache size after (MB) | api | api + web | api + web + lint |
|---|---|---|---|
| npm | 12.9 | 169.8 | 235.7 |
pnpm (du) | 24.6 | 154.3 | 236.4 |
| Yarn 1 | 15.5 | 558.1 | 1,017.3 |
| Yarn 4 | 11.1 | 114.3 | 153.7 |
The per-project <code>node_modules</code> sizes were close in every manager: api 12.4 to 13.5 MB, web 64.5 to 73.3 MB, lint 68.8 to 77.6 MB. Yarn 4's node-modules linker wrote the most files (3,229 in web against 2,395 for npm) and its folders were the largest.
Why Yarn 1's cache is 1 GB
Vite and Vitest depend on esbuild and Rollup, which ship one tiny package per operating system and CPU (<code>@esbuild/darwin-arm64</code>, <code>@esbuild/win32-x64</code> and so on). npm, pnpm and Yarn 4 download only the one that fits this Mac. Yarn 1 downloaded and unpacked all of them. Its cache folder held 340 package folders; <strong>78 of them were these platform builds, 895.9 MB of the 1,017.3 MB (88%)</strong>: 52 esbuild packages at 806.6 MB and 26 Rollup packages at 89.2 MB. The two builds that run here, <code>@esbuild/darwin-arm64</code> (14.0 and 16.1 MB) and <code>@rollup/rollup-darwin-arm64</code> (2.9 MB), are about 33 MB of it. Yarn 4's cache held only 5 packages with those names (about 21.7 MB).
The practical meaning: if you still run Yarn 1 on a project that uses Vite, esbuild, SWC or Rollup, its cache folder is probably the biggest of your package caches. It is a cache, so deleting it is safe and the next install downloads again.
pnpm's store: not hard links on a Mac
pnpm's pitch is a single content-addressed store with project files linked to it. We checked what <code>stat</code> says. After the default install, all 10,771 files in the store had a link count of 1, and so did all 2,447 files in web's <code>node_modules</code>. On APFS, pnpm's default <code>package-import-method</code> clones the files (copy-on-write) instead of hard-linking them. <code>du</code> cannot see clones, which is the effect we measured in <a href="https://zofle.com/articles/apfs-clone-files-du-double-count-cp-c-free-space-measured">our APFS clones article</a>. We installed the web project alone with each import method into a fresh store:
| Import method | node_modules by du (MB) | Store by du (MB) | Link counts in node_modules/.pnpm | Space really used (free-space drop, MB) |
|---|---|---|---|---|
| default (auto) | 64.5 | 128.5 | all 2,442 files have 1 link | 138.4 |
hardlink | 65.4 | 65.7 | 2,286 files with 2 links, 74 with 3 | 131.6 |
copy | 64.5 | 64.7 | all 1 link | 206.8 |
Two details explain the table. First, in the default mode the store holds a second folder, <code>dir-clone-cache</code> (64.0 MB next to 63.9 MB of <code>files</code>), that pnpm uses to clone whole package folders at once; it is itself a clone of the same data, so <code>du</code> counts the store twice (131.6 MB) although the files add up to 115.3 MB. Second, the last column is the drop in free space on the volume (<code>df</code>) during the install. It includes pnpm's package-metadata cache in <code>~/Library/Caches/pnpm</code> (58.5 MB here), so it is larger than store plus project, and it moves by some MB between runs because other processes write too. Treat it as a guide, not a measurement to the MB.
To remove that noise we repeated the install three times per method from a copy of a finished store, so only the project import and the files pnpm re-added were counted. Free space fell by 62.2 to 70.5 MB with the default clone import, 64.2 to 77.0 MB with hard links and <strong>124.0 to 130.5 MB with copy</strong>. About 65 MB of each figure appears to be the store files pnpm wrote again in that run (it did not seem to reuse our copied store), so the comparison is the difference: clone and hard link add almost nothing for <code>node_modules</code> on top of the store, while copy doubles it. On this Mac the default is as cheap as hard links and does not need the project and store to share a link count.
One more pnpm behaviour that surprised us: pnpm 12 ended the web and lint installs with exit code 1 and <code>ERR_PNPM_IGNORED_BUILDS</code>, because esbuild's install script is not run until you allow it (<code>pnpm approve-builds</code>). The packages were installed and the sizes above are complete; a script that checks the exit code will fail.
Space outside the cache folder
- npm and node-gyp. After the npm run, the scratch home held
Library/Caches/node-gypat 66.3 MB: the Node 22.23.4 headers npm downloads when a package (herefsevents) has a native build step. On our real Mac the same folder is 64.5 MB. It sits outside the npm cache folder. The other three managers left nothing in their scratch homes. - pnpm metadata.
~/Library/Caches/pnpmheld 58.5 MB of package metadata after one install of the web project.pnpm store pruneprinted “Removed all cached metadata files”. - Yarn 4 metadata. 21.1 MB in
metadatabeside thecachefolder; it stayed afteryarn cache clean. - npx. On our real Mac
~/.npmis 1.75 GB:_cacache789 MB and_npx1,000 MB (18 folders of packages run once withnpx). The_npxfolder is separate from_cacache, which is the folder our cache test cleaned; we did not delete either on the real folder.
Where each manager keeps its cache, and what pruning freed
| Manager | Default location on a Mac | What we saw (scratch cache, our run) |
|---|---|---|
| npm | ~/.npm/_cacache (npm config get cache) | npm cache verify: checked 593 entries, 0.4 s, size unchanged (241,416 to 241,424 KB). npm cache clean --force: 235.8 MB to 0.4 MB (7 files left) |
| pnpm | ~/Library/pnpm/store/v11 (pnpm store path) plus ~/Library/Caches/pnpm | pnpm store prune with only web still installed: store 231.7 to 64.5 MB, 2,873 files and 199 packages removed. After web's node_modules was deleted too: 12 KB left, 2,335 files and 66 packages removed |
| Yarn 1 | ~/Library/Caches/Yarn/v6 (yarn cache dir) | yarn cache clean: 1,017.3 MB to 0 |
| Yarn 4 | ~/.yarn/berry/cache (global cache) | yarn cache clean: 157,392 to 21,612 KB (the metadata folder stays); --all afterwards freed nothing more |
pnpm's prune is different in kind: it keeps what an installed project still uses and removes the rest, so it is the only command here that tells you which packages nothing needs any more. The other three are all-or-nothing. pnpm's own messages reported 45.3 and 60.1 MB removed, about 105 MB of file contents, while <code>du</code> fell by 231 MB; the difference is the cloned <code>dir-clone-cache</code> counted by <code>du</code> and block rounding on thousands of small files.
What to do on your Mac
- Check the real sizes:
du -sh ~/.npm ~/Library/pnpm ~/Library/Caches/pnpm ~/Library/Caches/Yarn ~/.yarn/berry ~/Library/Caches/node-gyp 2>/dev/null. Folders you never used simply do not exist. - Yarn 1 with Vite, esbuild or Rollup in any project:
yarn cache cleanis a safe first step and can free hundreds of MB. - pnpm: read store sizes with
pnpm store pathand expectduto over-report on APFS. Runpnpm store pruneafter you delete old projects, and keep the default import method. - npm:
npm cache clean --forceempties_cacache; look at~/.npm/_npxseparately. The oldnode_modulesfolders of finished projects are usually the larger saving (see our developer caches article), and they come back with one install.
Zofle lists <code>node_modules</code> folders and package caches by size on disk, shows them next to your other developer caches, and moves what you pick to the Trash with Undo. Reinstalling re-downloads whatever you removed.
Zofle finds node_modules folders and package-manager caches by size on disk and moves your picks to the Trash with Undo.
Download Zofle for MacSources and method
- Run on 22 November 2026 on one Apple M4 Mac mini, macOS 27.2.1, Node 22.23.4 (Homebrew node@22). Tools installed from the npm registry into a scratch folder: pnpm 12.21.0, yarn 1.22.22, @yarnpkg/cli-dist 4.19.0; npm 10.9.9 came with Node. Dependency versions below the pinned top level resolved to what the registry served that day, so a later run can differ.
- Sizes are
du -skor the sum ofstatfile sizes; link counts arestat -f %l. The free-space figures aredf -kdeltas around each install and carry noise from other processes on the Mac (a 20-second idle control moved by under 2 MB). The pnpm import-method behaviour is what we observed on APFS with 12.21.0; pnpm's documentation describes thepackage-import-methodsetting and we did not test other file systems. - One run per manager. The scratch caches and projects were deleted afterwards; the real
~/.npm, pnpm and Yarn folders were only measured, never changed.
Zofle Pro news
People signing up now will get Zofle Pro, with more features, for free when we launch it.