LinuxCommandLibrary

bun-run

Run package.json scripts

TLDR

Run a script defined in package.json

$ bun run [script_name]
copy

Run a JavaScript or TypeScript file directly
$ bun run [path/to/file.ts]
copy

Run a file in "watch" mode (restarts automatically when the file changes)
$ bun run --watch [path/to/file.ts]
copy

Run a file using a specific configuration file
$ bun run --config [path/to/bunfig.toml] [path/to/file.ts]
copy

SYNOPSIS

bun run [<options>] <script> [-- <args>...]

PARAMETERS

--bun
    Execute with Bun runtime (default)

--node
    Execute with Node.js (requires Node installed)

--inspect
    Enable V8 inspector on default port

--inspect-brk
    Enable inspector and break on first line

--inspect-wait
    Wait for inspector connection before running

--hot
    Enable hot reloading (development mode)

--help
    Show help menu

--version
    Print version information

DESCRIPTION

bun run is a command from the Bun toolkit, an ultra-fast JavaScript runtime and package manager. It executes scripts defined in the package.json "scripts" section, much like npm run, but with dramatically improved speed thanks to Bun's JavaScriptCore engine, Zig-based implementation, and native OS APIs.

Bun automatically detects and runs npm/yarn/pnpm scripts using its own runtime by default. It also directly invokes binaries from node_modules/.bin (e.g., bun run eslint) without needing a script entry. Supports running JS/TS files, JSX, and more out-of-the-box, with no transpilation step.

Performance highlights include <1ms startup for simple scripts (vs. 200ms+ for npm), lower memory (10x less), and built-in support for TypeScript/ESM. Ideal for development workflows, CI/CD, and production deploys on Linux, macOS, and Windows.

Install via curl -fsSL https://bun.sh/install | bash. Bun is drop-in compatible with Node.js but faster everywhere.

CAVEATS

Requires Bun installed (>=1.0); no support for npm-specific lifecycle scripts; relative paths in scripts are from package root.

EXAMPLES

bun run dev # Run "dev" script
bun run build --prod # Pass args
bun run eslint src # Run binary directly

NON-SCRIPT USAGE

Runs node_modules/.bin/<script> or files like bun run index.ts if no package.json match.

HISTORY

Developed by Jarred Sumner; debuted in Bun 0.5.0 (September 2022). Evolved rapidly with Bun 1.0 (2023) stable release, adding --node flag in 1.1+. Focus on speed: now >30x faster than npm run for common scripts.

SEE ALSO

npm(1), yarn(1), pnpm(1), node(1)

Copied to clipboard