bun-exec
Execute package scripts or binaries
TLDR
Run a simple command
Run a command with flags
Run a command containing quotes
Run a combined shell command
Run a script file
SYNOPSIS
bun exec [options] [--] command [args…]
PARAMETERS
--bun
Executes the binary using Bun runtime (faster for JS/TS tools) instead of spawning a subprocess
-h, --help
Displays help and usage information
DESCRIPTION
The bun exec command, part of the Bun JavaScript runtime, allows seamless execution of binaries installed in the project's node_modules/.bin directory. Similar to npx or yarn dlx, it searches locally first, then up the directory tree, enabling quick runs of tools like linters, formatters, or bundlers without global installs or full paths.
By default, it spawns binaries as subprocesses for compatibility. Use --bun to run them within Bun's runtime, slashing startup times for JS/TS-based CLIs via Bun's fast transpilation and execution. Ideal for monorepos or scripts in package.json, it integrates with Bun's speedy package manager.
Install Bun via curl -fsSL https://bun.sh/install | bash, then bun add -d eslint and run bun exec eslint .. Supports passing arguments directly and -- to disambiguate.
CAVEATS
Requires Bun installation; searches node_modules from npm/yarn/Bun but optimized for Bun installs. Node-specific binaries may need --bun for full compatibility.
EXAMPLES
bun exec prettier --write src/**/*.js
bun exec --bun tsc --noEmit
bun exec cowsay 'Hello Bun!'
HISTORY
Introduced in Bun 0.5.0 (September 2022) by Jarred Sumner; evolved with Bun's 1.0 stable release (2023) for production use, emphasizing speed over npm equivalents.


