Skip to main content
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.
Running bun install will:
  • Install all dependencies, devDependencies, optionalDependencies, and peerDependencies
  • Run your project’s {pre|post}install and {pre|post}prepare scripts
  • Write a bun.lock lockfile 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.
Use this flag in CI to enforce reproducible builds. See also: 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)
This means multiple projects sharing the same dependency version use virtually no additional disk space. To clear the cache:
To use a custom cache location, set BUN_INSTALL_CACHE_DIR or configure bunfig.toml:

Non-npm dependencies

Bun supports installing dependencies from Git, GitHub, and remote tarballs directly in package.json.

Installation strategies

Bun supports two strategies for how packages are placed in node_modules.

Hoisted

The traditional npm/Yarn approach. All packages are flattened into the root node_modules directory.

Isolated

A pnpm-like approach that prevents phantom dependencies. A central store is created at node_modules/.bun/, and packages link only to their declared dependencies.
The default strategy depends on whether you’re starting a new project or migrating an existing one. New monorepos default to 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

All bun install behavior can be configured in bunfig.toml.

CI/CD

Use the official oven-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 a pnpm-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.
Bun also migrates workspace configuration from pnpm-workspace.yaml into the root package.json automatically.