bun-run
Run package.json scripts
TLDR
Run a script defined in package.json
Run a JavaScript or TypeScript file directly
Run a file in "watch" mode (restarts automatically when the file changes)
Run a file using a specific configuration file
SYNOPSIS
bun run [script_name] [--] [arguments...]
bun run <file_path> [--] [arguments...]
bun run <command> [--] [arguments...]
PARAMETERS
script_name
The name of a script defined in the "scripts" section of your package.json file.
<file_path>
The path to a .js, .ts, .jsx, or .tsx file to execute directly.
<command>
An executable command found within the node_modules/.bin directory, run without needing its full path.
--
An optional separator. Arguments following this will be passed directly to the script or file being executed, not to bun run itself.
[arguments...]
Additional arguments that are passed directly to the script or file being executed, either after the script name/file path or after the -- separator.
DESCRIPTION
bun run is the command-line utility within the Bun JavaScript runtime designed for executing scripts defined in a project's package.json file, or for running arbitrary JavaScript and TypeScript files. It serves a similar purpose to npm run or yarn run, but leverages Bun's native performance, resulting in significantly faster script execution. It automatically finds and executes binaries located in node_modules/.bin, simplifying development workflows. Bun is an all-in-one toolkit aiming to replace Node.js, npm, webpack, and other tools, offering a complete and optimized environment for web development. bun run is a core component, enabling seamless integration with existing projects while benefiting from Bun's speed and efficiency.
CAVEATS
Bun must be installed and configured on your system for bun run to function. While largely compatible, its behavior might differ in subtle ways from npm run or yarn run in specific environments or with complex shell scripts. Bun is still actively developed, and its CLI and runtime characteristics may evolve.
AUTOMATIC BINARIES
bun run intelligently resolves and executes command-line tools installed as dependencies (e.g., webpack, eslint) that are located in the node_modules/.bin directory. This means you can run bun run eslint without explicitly writing ./node_modules/.bin/eslint.
PASSING ARGUMENTS TO SCRIPTS
To pass arguments to the script being executed, place them after the script name or file path. If an argument might be misinterpreted by bun run (e.g., it starts with -), use the -- separator:
bun run my-script -- --some-flag --value
HISTORY
Bun was initially developed by Jarred Sumner and publicly launched in 2022, rapidly gaining attention for its focus on speed and 'all-in-one' philosophy. bun run was a foundational component of its CLI from the outset, designed to offer a familiar script execution interface while leveraging Bun's native, highly optimized runtime. Its development is ongoing, with frequent updates improving compatibility and performance across various platforms.


