bun install: Content-Addressable Global Cache & Linux clonefile/reflink
- Last updated
- Prerequisites:
- npm/yarn/pnpm package managers
- File system hardlinks vs symlinks
- bun
- package-manager
- bun-install
- hardlinks
- clonefile
- reflink
Read at your depth
The practical view
`bun install` is a drop-in replacement for `npm install` that is up to 25x faster. It uses a binary lockfile (`bun.lockb` or text `bun.lock` in Bun 1.2+) and a centralized global package cache located at `~/.bun/install/cache`. Instead of copying files, it uses the fastest available filesystem linking mechanism for your operating system.
The same idea in other frameworks
`npm install` (copies full files into `node_modules` per project).`pnpm install` (uses global content-addressable store with symlinks).`yarn install` (PnP or standard node_modules link).`bun install` (uses global cache with native OS `clonefile` / `reflink` / hardlinks).Legacy vs modern
npm install vs bun install
`npm install` takes minutes downloading and copying duplicate node_modules; `bun install` links in milliseconds.
npm install // ❌ Takes 30-90s, duplicates gigabytes of files across projectsbun install // ✅ NEW: Executes in <500ms using native OS clonefileInterview gotchas
Context
Interviewers test your knowledge of Bun's lockfile format and Git diffing.
The mechanical answer
`bun.lockb` is Bun's original **binary lockfile** format, designed for instant parsing without JSON deserialization overhead (saving ~100ms on startup). In Bun 1.2+, Bun introduced a human-readable text lockfile **`bun.lock`** (similar to yarn/pnpm) to make Git merge conflict resolution and code review diffs easy while retaining high install speeds.
Trap
You can inspect a binary `bun.lockb` in the terminal at any time by running `bun bun.lockb` or `bun lockfile`.
Context
Checks understanding of native system implementation vs Node.js runtime overhead.
The mechanical answer
While `pnpm` also uses a global store, it runs on Node.js and uses complex nested symlinks with JavaScript-level resolution. `bun install` is written entirely in compiled **Zig**, uses SIMD-accelerated JSON/lockfile parsing, executes concurrent network fetches in native C threads, and uses kernel-level Copy-on-Write (`clonefile`/`reflink`) directly.
Trap
Bun creates a standard flat `node_modules` structure by default, avoiding the symlink phantom-dependency traps that can occur with pnpm.