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 flatnode_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
Ifpackage.json includes a workspaces field, Bun will install dependencies for all workspace packages.
Configuration
Behavior can be configured inbunfig.toml: