---
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 will add the package to `peerDependencies` in `package.json`.

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

---

Running `bun install` will install peer dependencies by default, unless marked optional in `peerDependenciesMeta`.

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

---

See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
