Bun Add an optional dependency

Add an optional dependency

jarle Updated

File contents

Add an optional dependency

To add an npm package as an optional dependency, use the --optional flag.

bun add zod --optional

This will add the package to optionalDependencies in package.json.

{
  "optionalDependencies": {
    "zod": "^3.0.0" // [!code ++]
  }
}

See Docs > Package manager for complete documentation of Bun's package manager.

jarle/bun-skills/tree/main/skills/bun-guides-install-add-optional commit be79c554aa

Frequently asked questions

npx skillmds@latest add jarle/bun-add-an-optional-dependency