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
| Argument | Required | Description |
|---|---|---|
frozen_lockfile | No | Run npm ci instead of npm install. Defaults to False. |
omit | No | Unique dependency types to omit: "dev", "optional", or "peer". Defaults to []. |
ignore_scripts | No | Disable package lifecycle scripts. Defaults to False. |
audit | No | Enable npm's audit request. Defaults to True. |
deps | No | Dependencies 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,
)