> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/zhcndoc/bun/llms.txt
> Use this file to discover all available pages before exploring further.

# bun remove

Remove a dependency from `package.json` and uninstall it.

```bash theme={null}
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

```bash theme={null}
bun remove react
```

### Multiple packages

```bash theme={null}
bun remove react react-dom
```

### Scoped packages

```bash theme={null}
bun remove @types/node
```

## Flags

### `--global` (`-g`)

Remove a globally installed package.

```bash theme={null}
bun remove --global typescript
```

### `--cwd <path>`

Run command in specified directory.

```bash theme={null}
bun remove --cwd ./my-project react
```

### `--ignore-scripts`

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

```bash theme={null}
bun remove --ignore-scripts puppeteer
```

### `--dry-run`

Simulate removing packages without actually uninstalling.

```bash theme={null}
bun remove --dry-run react
```

### `--verbose`

Enable verbose logging.

```bash theme={null}
bun remove --verbose lodash
```

### `--silent`

Suppress all output except errors.

```bash theme={null}
bun remove --silent webpack
```

## Examples

### Remove a single package

```bash theme={null}
$ bun remove lodash
bun remove v1.0.0

 removed lodash

 1 package removed [89ms]
```

### Remove multiple packages

```bash theme={null}
$ bun remove react react-dom
bun remove v1.0.0

 removed react
 removed react-dom

 2 packages removed [156ms]
```

### Remove dev dependency

```bash theme={null}
$ bun remove typescript
bun remove v1.0.0

 removed typescript from devDependencies

 1 package removed [72ms]
```

### Remove with dry run

```bash theme={null}
$ bun remove --dry-run express
bun remove v1.0.0

[dry-run] Would remove:
  - express@4.18.2

 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`:

```bash theme={null}
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`:

```bash theme={null}
bun install
```

## Aliases

These commands are equivalent:

```bash theme={null}
bun remove <package>
bun rm <package>
bun uninstall <package>
```
