bun init: Scaffold a New Project
bun init creates a minimal Bun project in the current directory: package.json, a tsconfig, an entry file, and a .gitignore.
bun init is the empty-project starter. It is interactive by default, so the -y flag matters when you script it. For richer templates, bun create pulls from a starter.
What it does
bun init prompts for a package name and entry point, then writes a package.json, a tsconfig.json tuned for Bun, an index.ts, a README, and a .gitignore. With -y it accepts all defaults non-interactively.
Common usage
bun init # interactive
bun init -y # accept all defaults
mkdir myapp && cd myapp && bun init -yOptions
| Flag | What it does |
|---|---|
| -y / --yes | Accept default answers, no prompts |
| (directory) | Run inside the target directory; init uses the cwd |
In CI
If you generate a project in a pipeline (rare, mostly in tests of scaffolding), always pass -y so init does not block on prompts and hang the job. For application templates rather than an empty project, use bun create instead.
Common errors in CI
A hung job at "package name" means bun init is waiting on stdin; add -y. "package.json already exists" is informational; init will not overwrite an existing project without merging. Permission errors writing files mean a read-only working directory; init needs to write into the cwd.