Open-Source Wikis

/

Bun

/

Apps

/

Misc commands

oven-sh/bun

Misc commands

Active contributors: Jarred Sumner, Dylan Conway

This page covers smaller subcommands that don't warrant their own page.

bun init

Source: src/cli/init_command.zig (~54 KB), templates in src/cli/init/.

Bootstraps a new Bun project. Prompts for project name, type, and whether to add a tsconfig.json. Writes a minimal package.json, bunfig.toml (optional), .gitignore, and a starter index.ts. Templates are stored as inline strings in the source rather than fetched.

bun init -y skips prompts and uses defaults. bun init <template> accepts community templates from bun-create (see below).

bun create

Source: src/cli/create_command.zig (~108 KB).

Bootstraps a project from a template. Templates can be:

  • A built-in (bun create react app).
  • A create-<x> package on npm (bun create vite).
  • A GitHub repo (bun create <owner>/<repo>).
  • A local directory.

The implementation downloads the template, runs its post-create script (e.g. npx create-vite), and then runs bun install.

bun upgrade

Source: src/cli/upgrade_command.zig (~42 KB).

Self-update. Fetches the latest release tarball from GitHub Releases (or --canary from the canary tag), verifies the signature, replaces the running binary in place. Falls back to atomic rename + retry on Windows where the OS holds an exclusive lock on the running executable.

bun upgrade --canary switches to nightlies built from main.

bun repl

Source: src/cli/repl_command.zig (7 KB) plus src/repl.zig (67 KB).

A REPL backed by the runtime VM. Supports multi-line input, syntax highlighting, top-level await, and history (stored at ~/.bun_repl_history). The line editor is bun-internal (not GNU readline), implemented in src/repl.zig.

bun completions

Source: src/cli/install_completions_command.zig (~24 KB).

Installs shell completions for bash, zsh, and fish. Detects the shell from $SHELL and writes to the standard completion directory. Completion content for bun add arguments comes from src/cli/add_completions.zig (~301 KB) and add_completions.txt (a snapshot of popular npm package names).

bun update-cli / bun update --interactive

update-cli is an alias for bun upgrade. bun update --interactive is src/cli/update_interactive_command.zig and presents a TUI table of outdated dependencies for selective updates.

bun --print, bun -p

-p '<expr>' evaluates an expression and prints the result. Implementation lives in run_command.zig's runEval path. The result is console.log'd via ConsoleObject.zig's formatter.

bun -e

-e '<source>' evaluates a script. Same code path as -p but without the wrapping console.log. Useful for one-off snippets without writing a file.

bun --watch <file> / bun --hot <file>

Both are flags routed through src/bun.js/hot_reloader.zig. --watch re-runs the entry on any file change. --hot patches the running module graph in place. See Watcher & hot reload.

bun --inspect

Enables the WebSocket inspector protocol. Implementation: src/bun.js/Debugger.zig plus C++ glue in src/bun.js/bindings/BunInspector.cpp. Compatible with Chrome DevTools and the bundled bun-vscode extension (see packages/bun-vscode/).

bun discord

Source: src/cli/discord_command.zig (~270 bytes). Opens the Bun Discord invite URL. The whole "command" is two lines.

bun --help, bun help <cmd>

Help text is generated from the option list in src/cli/Arguments.zig. There's no dedicated help_command.zig.

Where to look for the rest

The full subcommand list is the Command enum near the top of src/cli.zig. Any name not covered above maps directly to its <name>_command.zig file under src/cli/.

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Misc commands – Bun wiki | Factory