nodejs
nodejs is a dependency that provisions the selected official Node.js distribution and puts its executable directory first in PATH. Use it when calling node directly through a general command runner. It is not a function and takes no arguments.
Load an exact stable x.y.z release or release candidate in the form x.y.z-rc.N, without a leading v. The exact host artifact must exist in Node.js's official release indexes and bundle npm and npx version 7 or newer.
On first use, xx verifies the official SHA-256 checksum and validates Node.js, npm, and npx before storing the distribution under xx/nodejs/<version> in the user cache. Valid distributions are reused; invalid ones are replaced. Supported hosts are Windows x86-64 and ARM64, Linux x86-64 and ARM64, and macOS ARM64.
Examples
Print the managed Node.js version
load("@[email protected]", "nodejs")
load("@os@1", "run")
run(("node", "--version"), deps=[nodejs])
Run a project script directly
load("@[email protected]", "nodejs")
load("@os@1", "env_set", "run")
run(
("node", "scripts/generate.mjs"),
deps=[nodejs, env_set("NODE_ENV", "production")],
)
Use npm_run for scripts declared in project-root package.json.