Skip to main content
Remove a dependency from package.json and uninstall it.
bun remove <package>

Behavior

bun remove removes the specified package(s) from package.json and deletes them from node_modules. The lockfile is updated to reflect the changes. The package is removed from all dependency types:
  • dependencies
  • devDependencies
  • optionalDependencies
  • peerDependencies

Arguments

Package name

bun remove react

Multiple packages

bun remove react react-dom

Scoped packages

bun remove @types/node

Flags

--global (-g)

Remove a globally installed package.
bun remove --global typescript

--cwd <path>

Run command in specified directory.
bun remove --cwd ./my-project react

--ignore-scripts

Skip running lifecycle scripts (preuninstall, uninstall, postuninstall).
bun remove --ignore-scripts puppeteer

--dry-run

Simulate removing packages without actually uninstalling.
bun remove --dry-run react

--verbose

Enable verbose logging.
bun remove --verbose lodash

--silent

Suppress all output except errors.
bun remove --silent webpack

Examples

Remove a single package

$ bun remove lodash
bun remove v1.0.0

 removed lodash

 1 package removed [89ms]

Remove multiple packages

$ bun remove react react-dom
bun remove v1.0.0

 removed react
 removed react-dom

 2 packages removed [156ms]

Remove dev dependency

$ bun remove typescript
bun remove v1.0.0

 removed typescript from devDependencies

 1 package removed [72ms]

Remove with dry run

$ bun remove --dry-run express
bun remove v1.0.0

[dry-run] Would remove:
  - [email protected]

 1 package would be removed

Lifecycle scripts

When removing a package, Bun runs these lifecycle scripts in order:
  1. preuninstall - Before uninstalling the package
  2. uninstall - During package removal
  3. postuninstall - After the package is removed
Skip scripts with --ignore-scripts:
bun remove --ignore-scripts <package>

Removing unused dependencies

To remove dependencies that are no longer listed in package.json, use bun install. This will clean up node_modules:
bun install

Aliases

These commands are equivalent:
bun remove <package>
bun rm <package>
bun uninstall <package>

Build docs developers (and LLMs) love