To add an npm package as a peer dependency, use the --optional
flag.
bun add zod --optional
This will add the package to optionalDependencies
in package.json
.
{
"optionalDependencies": {
"zod": "^3.0.0"
}
}
See Docs > Package manager for complete documentation of Bun's package manager.