Files
2026-08-27 21:09:14 +00:00

45 lines
791 B
Plaintext

---
title: Add a dependency
sidebarTitle: Add a dependency
mode: center
---
To add an npm package as a dependency, use `bun add`.
```sh terminal icon="terminal"
bun add zod
```
---
This adds the package to `dependencies` in `package.json`. By default, Bun uses the `^` range specifier, which accepts future minor and patch versions.
```json package.json icon="file-json"
{
"dependencies": {
"zod": "^4.0.0" // [!code ++]
}
}
```
---
To pin your project to the exact version you installed, use `--exact`. This adds the package to `dependencies` without the `^`.
```sh terminal icon="terminal"
bun add zod --exact
```
---
To specify an exact version or a tag:
```sh terminal icon="terminal"
bun add [email protected]
bun add zod@next
```
---
See [`bun install`](/pm/cli/install).