Skip to main content
Install all dependencies for a project.

Behavior

bun install reads package.json and installs all dependencies into the node_modules directory. If a lockfile (bun.lockb or bun.lock) exists, Bun will use it to ensure reproducible installs.

Installation strategies

Bun uses a hoisted installation strategy by default, placing packages in a flat node_modules structure to maximize compatibility with Node.js and other tools.

Lockfile

Bun generates a binary lockfile (bun.lockb) or text lockfile (bun.lock) to lock down exact package versions. The lockfile is automatically updated when dependencies change.

Performance

Bun installs packages significantly faster than other package managers by:
  • Using a global cache to avoid re-downloading packages
  • Installing packages in parallel with a fast native implementation
  • Using hardlinks/copying instead of symlinks when possible

Flags

--production

Skip installing devDependencies.

--frozen-lockfile

Don’t update the lockfile. Useful in CI/CD environments.

--no-save

Don’t save exact package versions to lockfile.

--dry-run

Perform a dry run without actually installing anything.

--force

Force re-download all packages, ignoring cache.

--global (-g)

Install a package globally.

--cwd <path>

Set the current working directory for the install.

--backend <backend>

Specify installation backend:
  • hardlink - Use hardlinks (fastest, default when possible)
  • clonefile - Use copy-on-write clones (macOS/Linux with supported filesystems)
  • copyfile - Copy files (most compatible, slowest)
  • symlink - Use symbolic links (compatibility mode)

--cache-dir <path>

Specify a custom cache directory.

--no-cache

Ignore the cache when installing packages.

--no-progress

Disable progress bar.

--no-summary

Don’t print summary after install.

--no-verify

Skip verifying package integrity.

--concurrent-scripts <number>

Set the number of scripts to run concurrently (default: number of CPU cores).

--ignore-scripts

Skip running lifecycle scripts (install, postinstall, etc).

--trust

Run scripts from specified packages even if they’re not trusted.

--verbose

Enable verbose logging.

--silent

Suppress all output except errors.

Workspaces

If package.json includes a workspaces field, Bun will install dependencies for all workspace packages.
See workspaces configuration for more details.

Configuration

Behavior can be configured in bunfig.toml:
See configuration for all available options.

Examples

Basic install

Install with frozen lockfile

Install without dev dependencies