Bun Add a dependency

Add a dependency

jarle Updated

File contents

Add a dependency

To add an npm package as a dependency, use bun add.

bun add zod

This will add the package to dependencies in package.json. By default, the ^ range specifier will be used, to indicate that any future minor or patch versions are acceptable.

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

To "pin" to an exact version of the package, use --exact. This will add the package to dependencies without the ^, pinning your project to the exact version you installed.

bun add zod --exact

To specify an exact version or a tag:

bun add zod@3.0.0
bun add zod@next

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

jarle/bun-skills/tree/main/skills/bun-guides-install-add commit 3e1da07137

Frequently asked questions

npx skillmds@latest add jarle/bun-add-a-dependency