xx
.md

npm_install

npm_install installs dependencies at project root with npm bundled in the selected Node.js distribution. It registers installation as a root task and returns a dependency for commands that must wait for installed packages.

Project-root package.json must be a regular, non-symlink file after dependencies finish. Root-package workspaces are supported. Installation is always project-local.

Arguments

ArgumentRequiredDescription
frozen_lockfileNoRun npm ci instead of npm install. Defaults to False.
omitNoUnique dependency types to omit: "dev", "optional", or "peer". Defaults to [].
ignore_scriptsNoDisable package lifecycle scripts. Defaults to False.
auditNoEnable npm's audit request. Defaults to True.
depsNoDependencies activated before installation, in list order. Defaults to [].

npm ci removes existing node_modules, requires a lockfile consistent with package.json, and does not update package metadata or lockfiles. Lifecycle scripts can run package-supplied code. npm audit sends dependency information to the configured registry.

The function reserves node_modules, package-lock.json, and npm-shrinkwrap.json, so declare it once per project execution.

Examples

Install project dependencies

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

npm_install()

Reproduce a lockfile install

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

npm_install(
    frozen_lockfile=True,
    audit=False,
)

Install production dependencies without lifecycle scripts

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

npm_install(
    frozen_lockfile=True,
    omit=["dev", "optional"],
    ignore_scripts=True,
    audit=False,
)