LinuxCommandLibrary

bun-x

Execute npm package binaries

TLDR

View documentation for the original command

$ tldr bunx
copy

SYNOPSIS

bun x [package_name[@version]] [arguments...]
bun x [arguments...]

PARAMETERS

package_name
    The name of the npm package to execute from the registry.

@version
    Optional: Specifies a particular version of the package to use (e.g., `@latest`, `@1.0.0`). If omitted, the latest stable version is used.

script_path
    A path to a local JavaScript or TypeScript file to execute directly.

arguments...
    Any additional arguments to pass directly to the executed binary or script.

DESCRIPTION

The command "bun-x" as a standalone Linux command does not exist in standard distributions. This analysis is based on the interpretation of "bun-x" as `bun x`, which is a subcommand of the Bun JavaScript runtime.

`bun x` is designed for efficiently executing binaries or scripts from npm packages without explicit installation. It functions similarly to `npx` from Node.js or `yarn dlx` from Yarn, allowing developers to run command-line tools, scaffold new projects (e.g., `create-react-app`), or test package functionalities.

When `bun x` is invoked with a package name, Bun intelligently checks its cache. If the package is not found or an update is available, Bun downloads and caches the necessary files, then executes the specified binary or default script. This "on-demand" execution model streamlines workflows, reduces disk space by avoiding numerous global installations, and ensures the latest version of a tool is used unless a specific version is requested. It is a core utility for modern JavaScript and TypeScript development within the Bun ecosystem, emphasizing speed and developer convenience.

CAVEATS

The command "bun-x" as a standalone Linux command does not exist in standard distributions. This analysis is based on the interpretation of "bun-x" as `bun x`, a subcommand of the Bun JavaScript runtime. Therefore, its usage requires the Bun runtime to be installed and configured on your system. This command's functionality is specific to the Bun ecosystem and JavaScript/TypeScript development.

CACHING MECHANISM

Bun utilizes a sophisticated caching mechanism for packages executed via `bun x`. Once a package is downloaded, it's cached locally, significantly speeding up subsequent executions. This reduces redundant downloads and improves developer experience, especially for frequently used tools and commands.

LOCAL SCRIPT EXECUTION

Beyond npm packages, `bun x` can also directly execute local JavaScript or TypeScript files. This provides a convenient way to run scripts without needing to mark them as executable or explicitly invoke a runtime like `bun run` or `node`. For example, `bun x ./my-script.ts`.

HISTORY

The `bun x` subcommand was introduced as an integral part of the Bun JavaScript runtime, which was first publicly announced in 2022. Bun aims to be a unified JavaScript toolkit offering a runtime, bundler, and package manager. `bun x` was developed to provide a modern, high-performance alternative to existing solutions like `npx` and `yarn dlx`, inheriting Bun's focus on speed and efficiency. Its development is ongoing, evolving with the broader Bun ecosystem to support new web technologies and developer workflows.

SEE ALSO

bun(1), npm(1) (npx subcommand), yarn(1) (yarn dlx subcommand)

Copied to clipboard