Skip to main content
bunx auto-installs and runs packages from npm. It is Bun’s equivalent of npx or yarn dlx.
bunx is an alias for bun x. Both are installed automatically when you install Bun.
bunx cowsay "Hello world!"
 _____________
< Hello world! >
 -------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
~100x faster than npx — For locally installed packages, bunx starts nearly 100x faster than npx because Bun’s startup time is dramatically lower and packages are served from a global cache.

How it works

Packages on npm can declare executables in the "bin" field of their package.json:
{
  "name": "my-cli",
  "bin": {
    "my-cli": "dist/index.js"
  }
}
bunx looks for a locally installed version of the package first, then falls back to auto-installing it from npm. Installed packages are stored in Bun’s global cache for future use, so subsequent runs are near-instant.

Running specific versions

bunx cowsay@1.5.0 "pinned version"
bunx create-react-app@latest my-app

Passing arguments and flags

Place arguments and flags after the executable name:
bunx my-cli --foo bar --baz

Using bun as the runtime

By default, bunx respects shebangs. If an executable has #!/usr/bin/env node, Bun spawns a node process to run it. To force execution under Bun’s runtime instead, add --bun before the executable name:
bunx --bun my-cli        # runs with Bun
bunx my-cli --bun        # --bun is passed to the CLI, not bunx

Specifying the package separately

When the binary name differs from the package name, use --package (or -p) to specify the package explicitly:
bunx --package @angular/cli ng new my-app
bunx -p renovate renovate-config-validator

Forcing Bun as the runtime in a script

To always run a script with Bun regardless of who invokes it, use a Bun shebang in the file:
#!/usr/bin/env bun

console.log("Running with Bun!");

Build docs developers (and LLMs) love