Skip to main content
Remove a dependency from package.json and uninstall it.

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

Multiple packages

Scoped packages

Flags

--global (-g)

Remove a globally installed package.

--cwd <path>

Run command in specified directory.

--ignore-scripts

Skip running lifecycle scripts (preuninstall, uninstall, postuninstall).

--dry-run

Simulate removing packages without actually uninstalling.

--verbose

Enable verbose logging.

--silent

Suppress all output except errors.

Examples

Remove a single package

Remove multiple packages

Remove dev dependency

Remove with dry run

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:

Removing unused dependencies

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

Aliases

These commands are equivalent: