$linuxjunkies
>

bun(1)

Bun is a fast JavaScript runtime and package manager that serves as a drop-in replacement for Node.js and npm.

UbuntuDebianFedoraArch

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

FlagWhat it does
--helpShow help information for the command
--versionDisplay the Bun version
-d, --debugEnable debug logging output
--bunfileSpecify a custom bunfile.toml configuration file
-b, --bunForce using Bun as the runtime (useful in scripts)
--node-modulesSpecify node_modules installation strategy (hoisted or local)
-eExecute code passed as an argument

Examples

Run a TypeScript file directly without compilation

bun script.ts

Install dependencies from package.json (faster npm alternative)

bun install

Add a package to your project

bun add lodash

Run test files matching *.test.ts or *.test.js patterns

bun test

Execute the 'dev' script defined in package.json

bun run dev

Create a new React application using a starter template

bun create react app-name

Execute inline JavaScript code

bun -e "console.log('Hello')"

Bundle a TypeScript file to the dist directory

bun build ./src/index.ts --outdir ./dist

Related commands