> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/oven-sh/bun/llms.txt
> Use this file to discover all available pages before exploring further.

# bunx

> Run a package from npm without installing it globally, like npx but significantly faster.

`bunx` auto-installs and runs packages from npm. It is Bun's equivalent of `npx` or `yarn dlx`.

<Note>
  `bunx` is an alias for `bun x`. Both are installed automatically when you install Bun.
</Note>

```bash theme={null}
bunx cowsay "Hello world!"
```

```
 _____________
< Hello world! >
 -------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
```

<Note>
  **\~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.
</Note>

## How it works

Packages on npm can declare executables in the `"bin"` field of their `package.json`:

```json theme={null}
{
  "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](/pm/global-cache) for future use, so subsequent runs are near-instant.

## Running specific versions

```bash theme={null}
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:

```bash theme={null}
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:

```bash theme={null}
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:

```bash theme={null}
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:

```js theme={null}
#!/usr/bin/env bun

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