bun-run
Execute files and package scripts
TLDR
Run a JavaScript/TypeScript file
SYNOPSIS
bun run [options] file|script [arguments]
bun file|script [arguments]
DESCRIPTION
bun run executes JavaScript, TypeScript, and JSX files using Bun's fast native transpiler. It can also run package.json scripts with lifecycle hook support.
The command can be shortened to just bun followed by the file or script name, though built-in commands take precedence.
PARAMETERS
--watch
Re-run on file changes--eval, -e code
Evaluate argument as script--print, -p code
Evaluate and print result--env-file file
Load environment variables from file--cwd directory
Set working directory--silent
Suppress script output
BEHAVIOR
Source files
Paths starting with ./ or absolute paths run as source filesPackage scripts
Scripts defined in package.json are executed with lifecycle hooks (pre/post)Resolution
With bun run, package.json scripts take precedence over files with same name
LIFECYCLE HOOKS
Bun respects pre and post lifecycle hooks. Running bun run build will execute prebuild, build, and postbuild in order. If a pre-script fails, the main script is not executed.
CAVEATS
TypeScript and JSX are transpiled on-the-fly without configuration. Startup time is significantly faster than npm run. Some Node.js-specific APIs may not be available.
