bun install reads your package.json and installs all dependencies into node_modules. It is a drop-in replacement for npm install, yarn install, and pnpm install and works in any existing Node.js project.
bun install will:
- Install all
dependencies,devDependencies,optionalDependencies, andpeerDependencies - Run your project’s
{pre|post}installand{pre|post}preparescripts - Write a
bun.locklockfile to the project root
25x faster — Bun’s package manager benchmarks up to 25x faster than
npm install on a warm cache, thanks to its global cache and efficient hard-linking strategy.Flags
--production
Install only dependencies, skipping devDependencies and optionalDependencies.
--frozen-lockfile
Install exact versions from bun.lock. Exits with an error if package.json disagrees with the lockfile. The lockfile is never updated.
bun ci, which is equivalent.
--no-save
Install packages without creating or updating the lockfile.
--dry-run
Resolve packages and show what would be installed, without writing anything to disk.
--omit
Exclude specific dependency types from installation.
--lockfile-only
Resolve and write bun.lock without installing packages into node_modules.
Global cache
Bun stores all downloaded packages in a global cache at~/.bun/install/cache. When a package is already cached, Bun reuses it instead of downloading again. Packages are linked from the cache into node_modules using the fastest available system call:
- Linux and Windows: hardlinks (files occupy disk space only once)
- macOS:
clonefile(copy-on-write, no extra disk usage)
BUN_INSTALL_CACHE_DIR or configure bunfig.toml:
Non-npm dependencies
Bun supports installing dependencies from Git, GitHub, and remote tarballs directly inpackage.json.
Installation strategies
Bun supports two strategies for how packages are placed innode_modules.
Hoisted
The traditional npm/Yarn approach. All packages are flattened into the rootnode_modules directory.
Isolated
A pnpm-like approach that prevents phantom dependencies. A central store is created atnode_modules/.bun/, and packages link only to their declared dependencies.
isolated; single-package projects and existing projects (pre-v1.3.2) default to hoisted.
.npmrc compatibility
Bun reads.npmrc files for registry and scope configuration, making it compatible with existing npm setups without any changes. See Registries & Scopes for details.
bunfig.toml configuration
Allbun install behavior can be configured in bunfig.toml.
CI/CD
Use the officialoven-sh/setup-bun GitHub Action to install Bun in CI:
bun ci is equivalent to bun install --frozen-lockfile. It requires bun.lock to be committed to version control.
pnpm migration
When apnpm-lock.yaml is present and no bun.lock exists, Bun automatically migrates the lockfile to bun.lock format during installation. The original pnpm-lock.yaml is left untouched.
pnpm-workspace.yaml into the root package.json automatically.