| name | bun-package-manager |
| user-invocable | false |
| description | Use when managing dependencies with Bun's package manager. Covers installing packages, workspaces, lockfiles, and migrating from npm/yarn/pnpm to Bun. |
| allowed-tools | ["Read","Write","Edit","Bash","Grep","Glob"] |
Bun Package Manager
Use this skill when managing dependencies with Bun's package manager, which is significantly faster than npm, yarn, and pnpm while maintaining compatibility.
Key Concepts
Installing Dependencies
Bun's package manager is drop-in compatible with npm:
bun install
bun add express
bun add -d typescript
bun add -g cowsay
bun add react@18.2.0
bun add git@github.com:user/repo.git
bun add ./local-package
Removing Dependencies
bun remove express
bun remove -d typescript
Updating Dependencies
bun update
bun update react
bun update react --latest
Running Scripts
Execute package.json scripts:
bun run dev
bun run build
bun run test
bun dev
bun build
bun test
Best Practices
Use bun.lockb
Bun's binary lockfile is faster and more reliable:
bun install
git add bun.lockb
Workspaces
Manage monorepos with workspaces:
{
"name": "my-monorepo",
"workspaces": ["packages/*", "apps/*"]
}
bun install
bun --filter my-package run build
bun --filter '*' run test
Package.json Configuration
Configure Bun-specific options:
{
"name": "my-app",
"version": "1.0.0",
"type": "module",
"scripts": {
"dev": "bun run --hot src/index.ts",
"build": "bun build src/index.ts --outdir dist",
"start": "bun run dist/index.js",
"test": "bun test"
},
"dependencies": {
"express": "^4.18.0"
},
"devDependencies": {
"@types/express": "^4.17.0",
"bun-types": "latest"
},
"peerDependencies": {
"typescript"
TypeScript Configuration
Set up proper TypeScript support:
{
"compilerOptions": {
"lib": ["ESNext"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"jsx": "react-jsx",
"allowJs": true,
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,
"strict": true,
"skipLibCheck":
Using Trusted Dependencies
Configure trusted dependencies for faster installs:
bun pm trust @prisma/client
bun install --production --frozen-lockfile
Common Patterns
Migration from npm/yarn/pnpm
rm package-lock.json yarn.lock pnpm-lock.yaml
bun install
Private Package Registry
Configure private registry:
bun config set registry https://registry.example.com
bun config set @myorg:registry https://registry.example.com
bun config set //registry.example.com/:_authToken YOUR_TOKEN
CI/CD Installation
Optimize for CI environments:
bun install --frozen-lockfile --production
bun install --no-save
Development Workflow
bun install
bun --hot run src/index.ts
bun test --watch
bun run build
Monorepo Scripts
{
"scripts": {
"dev": "bun --filter '*' run dev",
"build": "bun --filter '*' run build",
"test": "bun --filter '*' run test",
"lint": "bun --filter '*' run lint"
}
}
{
"name": "@myorg/shared",
"scripts": {
"dev": "bun run --hot src/index.ts",
"build": "bun build src/index.ts --outdir dist",
"test": "bun test"
}
}
Link Local Packages
bun link
bun link @myorg/my-package
bun unlink @myorg/my-package
Anti-Patterns
Don't Mix Package Managers
npm install react
bun add express
yarn add vue
bun add react express vue
Don't Commit node_modules
git add node_modules
git add bun.lockb
echo "node_modules" >> .gitignore
Don't Install Packages Globally Unnecessarily
bun add -g typescript
bun add -d typescript
bunx tsc --version
Don't Skip Lockfile in CI
bun install
bun install --frozen-lockfile
Don't Ignore Peer Dependencies
bun add react-dom
bun add react react-dom
Performance Tips
Faster Installs
bun install
bun install --no-optional
bun install --production
bun install --frozen-lockfile
Cache Management
bun pm cache rm
bun pm cache
Parallel Installation
Bun installs packages in parallel automatically, making it significantly faster than npm/yarn/pnpm.
Troubleshooting
Check Package Info
bun pm ls express
bun pm ls
bun outdated
Fixing Lockfile Issues
rm bun.lockb
bun install
bun install --frozen-lockfile
Related Skills
- bun-runtime: Understanding Bun's runtime for dependency usage
- bun-testing: Testing with Bun and managing test dependencies
- bun-bundler: Building projects with installed dependencies