Bun Commands
JavaScript runtime, bundler and package manager.All Bun pages
- bun add: install a package with Bun (dev, exact, global)bun add pkg installs a package and saves it to package.json and bun.lock. Add -d for devDependencies, --exact to pin, -g for global tools, and trust scripts.
- bun build ./index.ts --outdir ./out: bundle with Bunbun build bundles TypeScript or JavaScript and its imports into files for the browser or Bun. Use --outdir, --target, --minify, and --compile for an executable.
- bun run index.ts: run a TypeScript file with Bunbun run file.ts (or bun file.ts) executes TypeScript directly: Bun strips types without a build step but does not type-check. Add tsc --noEmit for type errors.
- bun test: run tests with Bun's built-in test runnerbun test finds *.test.ts and *_spec files and runs them with a Jest-compatible API from bun:test. Filter by name, watch mode, coverage and exit codes explained.