bunx is an alias for bun x. The bunx CLI is auto-installed when you install bun.bunx to auto-install and run packages from npm. It’s Bun’s equivalent of npx or yarn dlx.
terminal
⚡️ Speed — With Bun’s fast startup times,
bunx is roughly 100x
faster than npx for locally installed packages."bin" field of their package.json. These are known as package executables or package binaries.
package.json
node.
bunx:
terminal
npx, bunx checks for a locally installed package first, then falls back to auto-installing it from npm. Installed packages are 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.terminal
Shebangs
By default, Bun respects shebangs. If an executable is marked with#!/usr/bin/env node, Bun spins up a node process to execute the file. To run the executable with Bun’s runtime instead, pass the --bun flag.
terminal
--bun flag must occur before the executable name. Flags that appear after the name are passed through to the executable.
terminal
Package flag
--package <pkg> or -p <pkg> - Run a binary from a specific package. Useful when the binary name differs from the package name:
terminal
bun shebang.
Usage
node_modules, Bun installs it into a global shared cache.
Flags
Force the command to run with Bun instead of Node.js, even if the executable contains a Node shebang (
#!/usr/bin/env node)Specify package to install when binary name differs from package name
Skip installation if package is not already installed
Enable verbose output during installation
Suppress output during installation
Examples
terminal