Bun's cache, and why its node_modules cost less than they look
Bun keeps one global package cache in ~/.bun/install/cache and clones from it into projects. Where it lives, how to clear it, and what it really costs.
Bun installs packages from a single global cache, then places them into each project's node_modules. On a Mac it does that with APFS clones, which is why a Bun project's node_modules can look as large as an npm one in Finder and cost far less on disk.
Where Bun keeps things
| Path | What |
|---|---|
~/.bun/bin/bun | The runtime, one self-contained binary |
~/.bun/install/cache | Every package version ever installed, shared by all projects |
~/.bun/install/global | Packages from bun add -g |
node_modules in each project | Clones of cache entries |
bun pm cache # prints the cache path
du -sh ~/.bun/* ~/.bun/install/* 2>/dev/null
# Clear it
bun pm cache rmWhy clones matter
A clone shares its data blocks with the original until one of them changes. Twenty projects that all use the same React version hold twenty directory entries but one copy of the bytes. du reports each clone at full size, so adding up node_modules folders overstates what deleting them would free. APFS clones and copies explains the mechanism, and Finder size versus Terminal size the reporting.
The practical consequence: clearing Bun's cache frees less than its size suggests while projects still hold clones of it, and deleting old projects frees less than their node_modules suggest while the cache is intact. To get space back you usually need both.
npm, Yarn and pnpm each have their own store, compared in the npm cache and Yarn and pnpm.
Common questions
Where is the Bun cache on a Mac?
In ~/.bun/install/cache by default. Run bun pm cache to print the exact path, which BUN_INSTALL_CACHE_DIR can change.
How do I clear the Bun cache?
Run bun pm cache rm. Packages are downloaded again the next time a project needs them.
Why does node_modules from Bun look so big?
Because tools count each APFS clone at full size. The clones share their data with Bun's cache, so the real cost on disk is lower.
How big is the Bun install itself?
Small. On the Mac measured, the bun binary was 57 MB and all of ~/.bun was 65 MB.