---
title: Add a peer dependency
sidebarTitle: Add a peer dependency
mode: center
---

To add an npm package as a peer dependency, use the `--peer` flag.

```sh terminal icon="terminal"
bun add @types/bun --peer
```

---

This adds the package to `peerDependencies` in `package.json`.

```json package.json icon="file-json"
{
  "peerDependencies": {
    "@types/bun": "^1.3.3" // [!code ++]
  }
}
```

---

`bun install` installs peer dependencies by default, unless they are marked optional in `peerDependenciesMeta`.

{/* prettier-ignore */}
```json package.json icon="file-json"
{
  "peerDependencies": {
    "@types/bun": "^1.3.3"
  },
  "peerDependenciesMeta": {
    "@types/bun": { // [!code ++]
      "optional": true // [!code ++]
    } // [!code ++]
  }
}
```

---

See [`bun install`](/pm/cli/install).
