macOSLinux

Where Does Bun Store Its Cache?

Where Bun keeps its global package cache on macOS and Linux, and the variable and config that move it.

Last updated

Bun caches every registry package globally in ~/.bun/install/cache, filed as name@version folders. Repeat installs link from there instead of downloading, which is why the second install of anything feels instant.

The path bends three ways: BUN_INSTALL_CACHE_DIR wins outright, then the cache dir in bunfig.toml, then $BUN_INSTALL or XDG roots. Check the env vars first when the folder seems missing, since version managers and CI images love relocating it.

Where Bun stores this, by platform

macOS
~/.bun/install/cache

Same path on Intel and Apple Silicon. Override with BUN_INSTALL_CACHE_DIR or [install.cache] dir in bunfig.toml. Clear with bun pm cache rm.

Linux
~/.bun/install/cache

Respects $XDG_CACHE_HOME and $BUN_INSTALL when set. Without a home directory Bun falls back to node_modules/.bun-cache in the project.

Frequently asked questions

Is it safe to delete the Bun cache?

Delete ~/.bun/install/cache (or run bun pm cache rm). It is purely a download cache: installs refetch whatever projects still need. That makes it the safest big folder in the JavaScript toolchain to empty.

How is the Bun cache organized inside?

Inside the cache, each package gets a name@version folder, so multiple versions coexist without conflict. Corrupt installs usually mean one bad version folder: delete just that one and reinstall instead of wiping the whole cache.

Notice an outdated path? Let us know.