bunx - BunDocumentation Index Search...⌘KInstall Bun Search...Navigation Core Commands bunxRuntimePackage ManagerBundlerTest RunnerGuidesReferenceBlogFeedback:first-child]:!hidden peer-[.is-custom]:[&>:first-child]:sm:!hidden peer-[.is-custom]:[&>:first-child]:md:!hidden peer-[.is-custom]:[&>:first-child]:lg:!hidden peer-[.is-custom]:[&>:first-child]:xl:!hidden">Core Commandsbun installbun addbun removebun updatebunxPublishing & Analysisbun publishbun outdatedbun whybun auditbun infoWorkspace ManagementWorkspacesCatalogsbun linkbun pmAdvanced Configurationbun patchbun --filterGlobal cacheGlobal virtual storeIsolated installsLockfileLifecycle scriptsScopes and registriesOverrides and resolutionsSecurity Scanner API.npmrc support On this pageArguments and flagsShebangsPackage flagUsageFlagsExamplesCore Commandsbunx Copy pagespan]:line-clamp-1 overflow-hidden group flex items-center py-0.5 gap-1 text-sm text-gray-950/50 dark:text-white/50 group-hover:text-gray-950/70 dark:group-hover:text-white/70 rounded-none rounded-r-xl border px-3 border-gray-200 aspect-square dark:border-white/[0.07] bg-background-light dark:bg-background-dark hover:bg-gray-600/5 dark:hover:bg-gray-200/5" aria-label="More actions" type="button" id="radix-_R_2shjllfium6abasnpfiulb_" aria-haspopup="menu" aria-expanded="false" data-state="closed"> *]:[overflow-wrap:anywhere]"> Copy pagespan]:line-clamp-1 overflow-hidden group flex items-center py-0.5 gap-1 text-sm text-gray-950/50 dark:text-white/50 group-hover:text-gray-950/70 dark:group-hover:text-white/70 rounded-none rounded-r-xl border px-3 border-gray-200 aspect-square dark:border-white/[0.07] bg-background-light dark:bg-background-dark hover:bg-gray-600/5 dark:hover:bg-gray-200/5" aria-label="More actions" type="button" id="radix-_R_5hjllfium6abasnpfiulb_" aria-haspopup="menu" aria-expanded="false" data-state="closed"> 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 or -p - Run binary from specific package. Useful when binary name differs from package name:
terminal Yes NoSuggest editsRaise issuebun updatePreviousbun publishNext⌘I xgithubdiscordyoutubePowered byThis documentation is built and hosted on Mintlify, a developer documentation platform
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
Skip to main contentBun home pageRun packages from npm
bunx cowsay "Hello world!"
{
// ... 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.
dist/index.js#!/usr/bin/env node
console.log("Hello world!");
These executables can be run with bunx,
terminalbunx my-cliAs 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
bunx my-cli --foo barShebangs 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
bunx --bun my-cliThe --bun flag must occur before the executable name. Flags that appear after the name are passed through to the executable. terminal
bunx --bun my-cli # good bunx my-cli --bun # badPackage flag --package
bunx -p renovate renovate-config-validator bunx --package @angular/cli ngTo force bun to always be used with a script, use a shebang. dist/index.js
#!/usr/bin/env bunUsage
bunx [flags] package>[@version] [flags and arguments for the package]Execute an npm package executable (CLI), automatically installing into a global shared cache if not installed in node_modules. Flags --bunbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Force the command to run with Bun instead of Node.js, even if the executable contains a Node shebang (#!/usr/bin/env node) -p, --packagestringp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Specify package to install when binary name differs from package name --no-installbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Skip installation if package is not already installed --verbosebooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Enable verbose output during installation --silentbooleanp:first-child]:mt-0 [&_.prose>p:last-child]:mb-0" data-component-part="field-content">Suppress output during installation Examples terminal
# Run Prisma migrations bunx prisma migrate # Format a file with Prettier bunx prettier foo.js # Run a specific version of a package bunx uglify-js@3.14.0 app.js # Use --package when binary name differs from package name bunx -p @angular/cli ng new my-app # Force running with Bun instead of Node.js, even if the executable contains a Node shebang bunx --bun vite dev foo.js
Was this page helpful?
bunx - Bun,AI智能索引,全网链接索引,智能导航,网页索引
- Run packages from npm