LinuxCommandLibrary

bun-install

Install project dependencies

TLDR

Install all dependencies listed in package.json

$ bun [[i|install]]
copy

Install a single package (this is an alias for bun add)
$ bun [[i|install]] [package_name]@[version]
copy

Install a package globally
$ bun [[i|install]] [[-g|--global]] [package_name]
copy

Install only production dependencies (skips devDependencies)
$ bun [[i|install]] --production
copy

Install dependencies exactly from the bun.lockb lockfile (frozen lockfile)
$ bun [[i|install]] --frozen-lockfile
copy

Force re-download all packages from the registry, ignoring the cache
$ bun [[i|install]] [[-f|--force]]
copy

SYNOPSIS

bun install [options] [package…]
bun i [options] [package…]

PARAMETERS

-g, --global
    Install packages globally into ~/.bun/install/cache.

-D, --dev
    Add package as devDependencies in package.json.

-O, --optional
    Add as optionalDependencies.

-P, --peer
    Add as peerDependencies.

-p, --production
    Skip devDependencies, optionalDependencies, and peerDependencies.

--frozen-lockfile
    Fail if bun.lockb needs updating; ensures exact lockfile match.

--ignore-scripts
    Skip running lifecycle scripts like postinstall.

--dry-run
    Simulate install without changes.

--verbose
    Enable verbose logging.

--force
    Force reinstall even if up-to-date.

--network-timeout <ms>
    Timeout for network requests.

DESCRIPTION

The bun install command is the primary package management tool in Bun, a high-performance JavaScript/TypeScript runtime and bundler. It installs dependencies listed in package.json or specified on the command line, generating or updating a binary bun.lockb lockfile for reproducible installs.

Bun install is optimized for speed, often 10-30x faster than npm install or yarn install due to native C++ implementation, parallel downloads, cheap JSON parsing, and filesystem optimizations. It supports npm, Yarn, and pnpm lockfiles (with some limitations) and runs npm-style lifecycle scripts.

Without arguments, it installs all dependencies. Specifying packages adds them to package.json (saved by default). Use flags like --production to skip devDependencies or --global for system-wide installs. Ideal for Node.js projects seeking faster dependency management without changing workflows.

CAVEATS

Binary bun.lockb lockfile is not human-readable; use bun lockfile --hash for hashes. Limited compatibility with some npm features like overrides. Global installs may conflict with npm globals.

LOCKFILE FORMAT

Generates bun.lockb (binary, compact) instead of JSON; supports offline installs and yarn/pnpm imports.

ALIASES

bun i is shorthand for bun install.

PERFORMANCE TIPS

Use --frozen-lockfile in CI; parallelizes resolutions and fetches across CPU cores.

HISTORY

Introduced in Bun 0.1.0 (Sep 2022) by Jarred Sumner. Evolved rapidly with Bun releases; v1.0 (2023) added full npm registry compatibility and lockfile optimizations for 20-50x speedups over npm.

SEE ALSO

npm(1), yarn(1), pnpm(1)

Copied to clipboard