mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
28 lines
544 B
Plaintext
28 lines
544 B
Plaintext
---
|
|
title: Add an optional dependency
|
|
sidebarTitle: Add an optional dependency
|
|
mode: center
|
|
---
|
|
|
|
To add an npm package as an optional dependency, use the `--optional` flag.
|
|
|
|
```sh terminal icon="terminal"
|
|
bun add zod --optional
|
|
```
|
|
|
|
---
|
|
|
|
This will add the package to `optionalDependencies` in `package.json`.
|
|
|
|
```json package.json icon="file-json"
|
|
{
|
|
"optionalDependencies": {
|
|
"zod": "^3.0.0" // [!code ++]
|
|
}
|
|
}
|
|
```
|
|
|
|
---
|
|
|
|
See [Docs > Package manager](https://bun.com/docs/cli/install) for complete documentation of Bun's package manager.
|