Files
bun.sh/docs/cli/bunx.md
robobun 41be6aeb3c docs: add missing v1.2.21 features to documentation (#23085)
## Summary
- Added documentation for 5 features introduced in Bun v1.2.21 that were
missing from the docs
- Kept updates minimal with high information density as requested

## Changes
- **bun audit filtering options** (`docs/install/audit.md`)
  - `--audit-level=<low|moderate|high|critical>` - filter by severity
  - `--prod` - audit only production dependencies  
  - `--ignore <CVE>` - ignore specific vulnerabilities

- **--compile-exec-argv flag** (`docs/bundler/executables.md`)
  - Embed runtime arguments in compiled executables
  - Arguments available via `process.execArgv`

- **bunx --package/-p flag** (`docs/cli/bunx.md`)
  - Run binaries from specific packages when name differs

- **package.json sideEffects glob patterns** (`docs/bundler/index.md`)
  - Support for `*`, `?`, `**`, `[]`, `{}` patterns

- **--user-agent CLI flag** (`docs/cli/run.md`)
  - Customize User-Agent header for all fetch() requests

## Test plan
- [x] Reviewed all changes match Bun v1.2.21 blog post features
- [x] Verified documentation style is concise with code examples
- [x] Checked no existing documentation was removed

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Bot <claude-bot@bun.sh>
Co-authored-by: Claude <noreply@anthropic.com>
2025-09-29 21:54:34 -07:00

2.8 KiB
Raw Blame History

{% callout %} Notebunx is an alias for bun x. The bunx CLI will be auto-installed when you install bun. {% /callout %}

Use bunx to auto-install and run packages from npm. It's Bun's equivalent of npx or yarn dlx.

$ bunx cowsay "Hello world!"

{% callout %} Speed — With Bun's fast startup times, bunx is roughly 100x faster than npx for locally installed packages. {% /callout %}

Packages can declare executables in the "bin" field of their package.json. These are known as package executables or package binaries.

{
  // ... other fields
  "name": "my-cli",
  "bin": {
    "my-cli": "dist/index.js"
  }
}

These executables are commonly plain JavaScript files marked with a shebang line to indicate which program should be used to execute them. The following file indicates that it should be executed with node.

#!/usr/bin/env node

console.log("Hello world!");

These executables can be run with bunx,

$ bunx my-cli

As with npx, bunx will check for a locally installed package first, then fall back to auto-installing the package from npm. Installed packages will be stored in Bun's global cache for future use.

Arguments and flags

To pass additional command-line flags and arguments through to the executable, place them after the executable name.

$ bunx my-cli --foo bar

Shebangs

By default, Bun respects shebangs. If an executable is marked with #!/usr/bin/env node, Bun will spin up a node process to execute the file. However, in some cases it may be desirable to run executables using Bun's runtime, even if the executable indicates otherwise. To do so, include the --bun flag.

$ bunx --bun my-cli

The --bun flag must occur before the executable name. Flags that appear after the name are passed through to the executable.

$ bunx --bun my-cli # good
$ bunx my-cli --bun # bad

Package flag

--package <pkg> or -p <pkg> - Run binary from specific package. Useful when binary name differs from package name:

bunx -p renovate renovate-config-validator
bunx --package @angular/cli ng

To force bun to always be used with a script, use a shebang.

#!/usr/bin/env bun