Clear the Bun Install Cache: Is ~/.bun/install/cache Safe to Delete?
~/.bun/install/cacheYes, it's safe to delete Bun's install cache. Everything in ~/.bun/install/cache is a spare copy of npm packages Bun already downloaded, kept so future installs can skip the network. Clear it and your next bun install quietly re-downloads whatever your projects still need. The official one-liner is bun pm cache rm.
What it is
When you run bun install, Bun downloads each package from the npm registry once and stores an extracted copy in ~/.bun/install/cache. On macOS it then clones those files into each project's node_modules using copy-on-write, which is why Bun feels instant on the second project that needs the same package. Think of the cache as the warehouse and node_modules as the storefront.
The folder grows because Bun keeps every version of every package it has ever fetched and never evicts anything on its own. Work across a few projects for six months and you accumulate old versions of the same libraries, packages from projects you already deleted, and dependencies of dependencies you never knew you had. A few hundred megabytes is normal for light use. On a machine that touches several JavaScript projects a week, it can reach several gigabytes.
Is it safe to delete?
Deleting the cache costs you nothing but bandwidth. Your existing projects keep working, because each node_modules folder holds its own copies of everything it needs. The only consequence is that the next bun install in each project re-downloads packages from the registry instead of pulling them from disk, so it runs slower exactly once. After that the cache is warm again.
There is no scenario where clearing this folder loses data. It holds no lockfiles, no configuration, and none of your code. Diskmack identifies this folder automatically and clears it the safe way if you'd rather not touch the terminal. The manual route below takes about a minute either way.
How to check its size
In Finder: In Finder, choose Go > Go to Folder (Command-Shift-G), enter ~/.bun/install and press Return. Select the cache folder and press Command-I. The Get Info window shows the total size of ~/.bun/install/cache.
In Terminal:
du -sh ~/.bun/install/cacheThe ~ expands to your home folder automatically.
How to clean it
- Close any terminal window that is currently running bun install.
- In Finder, choose Go > Go to Folder (Command-Shift-G) and enter ~/.bun/install/cache.
- Press Command-A to select everything inside, then move it to the Trash.
- Empty the Trash to actually reclaim the space.
The official way: this tool ships its own cleanup command, which handles locks and indexes correctly.
bun pm cache rmIf you moved the cache with the BUN_INSTALL_CACHE_DIR environment variable or the install.cache setting in bunfig.toml, it lives somewhere other than ~/.bun/install/cache. bun pm cache rm clears whichever location is configured, which is a good reason to prefer the command.
Will it come back?
Yes, and that is the point. The first bun install you run afterward re-downloads what that project needs and files it back into the cache. From there it grows at the pace of your work: new projects, dependency updates, and version bumps all add packages, and Bun never trims old ones by itself. Clearing it once or twice a year keeps it in check. If it hit multiple gigabytes once, expect roughly the same again after a few months of similar work.
Common questions
Will clearing the Bun cache break my existing projects?
No. Each project's node_modules folder contains its own copies of the installed packages, and those are untouched. The cache only feeds future installs.
Should I run bun pm cache rm or just delete the folder in Finder?
Both end in the same place. The command is slightly better because it clears the cache wherever it is actually configured, even if you relocated it with bunfig.toml or an environment variable.
Can I delete the whole ~/.bun folder instead?
Not unless you mean to uninstall Bun. Packages you installed globally with bun add -g live elsewhere under ~/.bun, and if you installed Bun with the official curl script, the bun binary itself sits in ~/.bun/bin. Stick to the install/cache subfolder.
Does Bun ever clean this cache on its own?
No. Bun keeps everything it downloads until you clear it. There is no built-in size cap and no expiry.