xx
.md

npx_run

npx_run runs npx <command>@<version> <args...> through managed Node.js. It does not require package.json. It registers a root task and returns its dependency.

npx may use a local package, use its cache, or download and execute a remote package. This function does not model npx-level options such as --yes, and the command cannot be an option. Use commands and registries you trust.

Arguments

ArgumentRequiredDescription
commandYesNon-empty command name that does not begin with -.
versionYesNon-empty package version, range, or tag appended to the command.
argsNoString arguments passed after the command. Defaults to [].
depsNoDependencies activated before npx, in list order. Defaults to [].

Examples

Run a pinned formatter

load("@[email protected]", "npx_run")

npx_run(
    "prettier",
    version="3.5.3",
    args=["--check", "."],
)

Run a command after installing project dependencies

load("@[email protected]", "npm_install", "npx_run")

install = npm_install(frozen_lockfile=True)
npx_run(
    "eslint",
    version="9.22.0",
    args=["."],
    deps=[install],
)