LinuxCommandLibrary

bun-add

Add packages to a Bun project

TLDR

Add a dependency

$ bun add [lodash]
copy
Add a dev dependency
$ bun add -D [jest]
copy
Add multiple packages
$ bun add [react] [react-dom]
copy
Add with exact version
$ bun add --exact [typescript@5.0.0]
copy
Add globally
$ bun add -g [typescript]
copy
Add from git repository
$ bun add git+https://github.com/[user]/[repo]
copy
Add as peer dependency
$ bun add -P [react]
copy
Dry run without changes
$ bun add --dry-run [package]
copy

SYNOPSIS

bun add [options] package ...

DESCRIPTION

bun add adds packages to package.json and installs them into node_modules. It updates or creates bun.lockb for reproducible installs. The command is significantly faster than npm or yarn alternatives.

PARAMETERS

-D, --dev

Add to devDependencies
-P, --peer
Add to peerDependencies
-O, --optional
Add to optionalDependencies
-E, --exact
Use exact version without ^ or ~ prefix
-g, --global
Install globally to Bun's global store
--production
Skip devDependencies
--registry url
Use custom npm registry
--lockfile-only
Update lockfile without installing
--dry-run
Simulate without making changes
--force
Force install despite warnings

PACKAGE SOURCES

Supports npm registry packages, semver ranges, git URLs (git+https://...), local paths (file:../path), and workspace packages (workspace:*).

CAVEATS

Creates bun.lockb lockfile format. Package versions default to caret (^) ranges unless --exact is specified. Global packages are stored in Bun's global store, not system-wide.

SEE ALSO

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community