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
| Argument | Required | Description |
|---|---|---|
command | Yes | Non-empty command name that does not begin with -. |
version | Yes | Non-empty package version, range, or tag appended to the command. |
args | No | String arguments passed after the command. Defaults to []. |
deps | No | Dependencies 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],
)