bun(1)
Bun is a fast JavaScript runtime and package manager that serves as a drop-in replacement for Node.js and npm.
Synopsis
bun [COMMAND] [OPTIONS] [ARGS]Description
Bun is a modern JavaScript runtime written in Zig that provides significantly faster performance than Node.js for running JavaScript and TypeScript files. It includes an integrated package manager, test runner, and bundler, eliminating the need for separate tools in many workflows.
You can use Bun to run .js, .ts, .jsx, and .tsx files directly without compilation steps. It supports CommonJS and ES modules, has built-in support for TypeScript and JSX, and aims for near-complete Node.js API compatibility.
Common options
| Flag | What it does |
|---|---|
--help | Show help information for the command |
--version | Display the Bun version |
-d, --debug | Enable debug logging output |
--bunfile | Specify a custom bunfile.toml configuration file |
-b, --bun | Force using Bun as the runtime (useful in scripts) |
--node-modules | Specify node_modules installation strategy (hoisted or local) |
-e | Execute code passed as an argument |
Examples
Run a TypeScript file directly without compilation
bun script.tsInstall dependencies from package.json (faster npm alternative)
bun installAdd a package to your project
bun add lodashRun test files matching *.test.ts or *.test.js patterns
bun testExecute the 'dev' script defined in package.json
bun run devCreate a new React application using a starter template
bun create react app-nameExecute inline JavaScript code
bun -e "console.log('Hello')"Bundle a TypeScript file to the dist directory
bun build ./src/index.ts --outdir ./dist