C.W.K.
Stream
Lesson 03 of 05 · published

Daily Bun Commands

~12 min · bun, commands, workflow

Level 0Newbie
0 XP0/55 lessons0/16 achievements
0/80 XP to next level80 XP to go0% complete

Bun's CLI is intentionally familiar — most npm/pnpm muscle memory transfers. The differences are where Bun adds something new.

bun add <pkg> adds a runtime dep, dramatically faster than npm. bun add -d <pkg> adds a dev dep. bun remove <pkg> removes one. bun install installs everything from bun.lock; bun install --frozen-lockfile is the CI mode.

bun run <script> runs a package.json script — or you can omit run for any script that's not a Bun built-in (bun build is Bun's own bundler, not your build script). bun index.ts runs a TypeScript file directly. bun test is the built-in test runner — Jest-compatible API, dramatically faster.

bun build is the bundler. bunx <tool> is Bun's npx. bun pm <subcommand> covers package-manager admin tasks like bun pm migrate (convert yarn.lock or pnpm-lock.yaml to bun.lock). bun audit is the security audit (added in v1.3). bun outdated shows what's behind the latest registry version.

Code

Daily Bun — npm-shaped, faster·bash
# Add / remove
bun add express
bun add -d vitest typescript
bun remove express

# Install
bun install
bun install --frozen-lockfile    # CI mode

# Run scripts
bun run build                    # explicit
bun build                        # Bun's bundler — different command
bun test                         # built-in test runner
bun dev                          # shorthand for 'bun run dev'

# Run a TS file directly — no compile
bun index.ts
bun src/server.tsx
Migrate + audit·bash
# Migrate from yarn or pnpm to Bun
bun pm migrate

# What's outdated?
bun outdated

# Security scan
bun audit

# Run a tool without installing
bunx create-vite my-app
Bun built-in bundler — fast, esbuild-class·bash
# Bundle a TypeScript entry point
bun build ./src/index.ts --outdir ./dist --minify

# Bundle for the browser
bun build ./src/index.tsx --outdir ./dist --target browser

# Watch mode
bun build ./src/index.ts --outdir ./dist --watch

External links

Exercise

In a real npm project, run 'bun pm migrate' and time the install: 'time bun install'. Compare to your previous 'time npm install'. The numbers are the lesson — and they're often dramatic enough to justify trying Bun on a new project tomorrow.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.