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

# Updating Packages

> Update dependencies to their latest versions with bun update and bun outdated.

## Checking for outdated packages

Use `bun outdated` to see which installed packages have newer versions available:

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

The output shows the current, wanted (within semver range), and latest versions for each outdated package:

```
Package       Current  Update   Latest
react         17.0.2   17.0.2   18.3.1
typescript    4.9.5    4.9.5    5.3.3
lodash        4.17.20  4.17.21  4.17.21
```

## Updating packages

### Update all packages

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

By default, `bun update` updates each package to the latest version that satisfies the version range in `package.json`. The `package.json` ranges themselves are not modified.

For example, if `package.json` specifies `"react": "^17.0.2"`, running `bun update` installs the latest `17.x` release but does not upgrade to `18.x`.

### Update a specific package

```bash theme={null}
bun update react
bun update typescript eslint
```

### Update beyond semver constraints

Use `--latest` to update to the absolute latest version, ignoring your `package.json` version ranges. This may include major version bumps.

```bash theme={null}
bun update --latest
bun update react --latest
```

`package.json` version ranges are rewritten to the new version.

## Interactive update

Use `--interactive` (or `-i`) for a terminal UI that lets you select exactly which packages to update:

```bash theme={null}
bun update --interactive
bun update -i
```

The interface shows packages grouped by dependency type with their current, target, and latest versions:

```
? Select packages to update - Space to toggle, Enter to confirm

  dependencies            Current  Target   Latest
    □ react               17.0.2   18.2.0   18.3.1
    □ lodash              4.17.20  4.17.21  4.17.21

  devDependencies         Current  Target   Latest
    □ typescript          4.8.0    5.0.0    5.3.3
    □ @types/node         16.11.7  18.0.0   20.11.5
```

**Keyboard controls:**

| Key       | Action                                                           |
| --------- | ---------------------------------------------------------------- |
| `Space`   | Toggle selection                                                 |
| `Enter`   | Confirm and update selected packages                             |
| `a`       | Select all                                                       |
| `n`       | Select none                                                      |
| `i`       | Invert selection                                                 |
| `l`       | Toggle between target and latest version for the current package |
| `↑` / `↓` | Move cursor                                                      |
| `Ctrl+C`  | Cancel without updating                                          |

Version changes are color-coded: red for major, yellow for minor, green for patch.

### Interactive update across workspaces

Use `--recursive` with `--interactive` to update dependencies across all workspaces in a monorepo:

```bash theme={null}
bun update --interactive --recursive
bun update -i -r
```

An additional "Workspace" column shows which workspace each dependency belongs to.

## Why is a package installed?

Use `bun pm why` to understand why a package appears in `node_modules`:

```bash theme={null}
bun pm why lodash
```

This traces the dependency chain from your root `package.json` to the package, showing which packages depend on it.

## Listing installed packages

Use `bun pm ls` to list all installed dependencies and their resolved versions:

```bash theme={null}
bun pm ls
```

Add `--all` to include transitive dependencies:

```bash theme={null}
bun pm ls --all
```
