Skip to main content
All packages downloaded from npm are stored in a global cache at ~/.bun/install/cache. The cache path can be overridden with the BUN_INSTALL_CACHE_DIR environment variable. Packages are stored in subdirectories named ${name}@${version}, so multiple versions of the same package can coexist in the cache.

Minimizing re-downloads

Bun avoids re-downloading packages whenever possible:
  • If a version already in the cache satisfies the requested range, Bun uses it directly.
  • If a matching version is already installed in node_modules, Bun skips both the download and the copy.
Bun checks node_modules by quickly parsing package.json in each package directory to compare name and version — without reading the whole file.

Fast copying into node_modules

After downloading a package into the cache, Bun links it into node_modules using the fastest syscall available on each platform:
  • Linux and Windows: hardlinks — the package files exist in one place on disk and are linked, not copied
  • macOS: clonefile — copy-on-write, so no additional disk space is consumed
You can override this with the --backend flag:
bun install --backend hardlink       # default on Linux/Windows
bun install --backend clonefile      # default on macOS
bun install --backend copyfile       # fallback, slowest
bun install --backend symlink        # for file: dependencies

Disk space savings

Because Bun uses hardlinks on Linux/Windows, the package files exist in exactly one location on disk even across many projects. A dependency used by 10 projects takes up the same space as if it were installed once. On macOS, clonefile is copy-on-write — the OS shares the underlying blocks until a file is modified, so disk usage is also minimal in practice.

Cache commands

Print the path to the global cache:
bun pm cache
Clear the entire global cache:
bun pm cache rm
Alternatively, delete the directory manually:
rm -rf ~/.bun/install/cache

Custom cache location

BUN_INSTALL_CACHE_DIR=/path/to/cache bun install

Disabling the cache

To bypass the cache and always resolve the latest versions from the registry:
[install.cache]
# don't load from the global cache
disable = false

# always re-fetch manifest data from the registry
disableManifest = false
Setting disable = true means Bun will not read from the cache, though it may still write to node_modules/.cache. Setting disableManifest = true forces a fresh resolution on every install.

Build docs developers (and LLMs) love