Skip to main content
bunx is an alias for bun x. The bunx CLI will be auto-installed when you install bun.
Use 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.
Packages can declare executables in the "bin" field of their package.json. These are known as package executables or package binaries.
package.json
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.
dist/index.js
These executables can be run with bunx,
terminal
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.
terminal

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.
terminal
The --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 binary from specific package. Useful when binary name differs from package name:
terminal
To force bun to always be used with a script, use a shebang.
dist/index.js

Usage

Execute an npm package executable (CLI), automatically installing into a global shared cache if not installed in node_modules.

Flags

boolean
Force the command to run with Bun instead of Node.js, even if the executable contains a Node shebang (#!/usr/bin/env node)
string
Specify package to install when binary name differs from package name
boolean
Skip installation if package is not already installed
boolean
Enable verbose output during installation
boolean
Suppress output during installation

Examples

terminal