Package manager is pinned
nodejs/package-manager-pinned@v1
The manifest names the package manager and the exact version Corepack should install.
| Id | nodejs/package-manager-pinned |
| Version | v1 |
| Category | nodejs |
| Default severity | warning |
| Interpreter | python3 |
| Timeout | 30 seconds |
| Violations tolerated | 0 |
| Collects | nodejs |
Collectors
This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.
| Collector | Gathers | Inputs it is given |
|---|---|---|
nodejs | The Node.js project in the project directory: its manifest, the Node version and package manager it asks for, every workspace it declares, the dependencies each manifest names and which of them are pinned, and the lock files committed beside them. | projectDir |
The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.
Configuration
{
"guardrails": {
"failOn": "error",
"comment": true,
"checks": [
{
"use": "nodejs/package-manager-pinned@v1",
"severity": "warning",
"with": {
"projectDir": "."
},
"exemptions": []
}
]
}
}Inputs
| Input | Description | Default | Environment variable |
|---|---|---|---|
projectDir | Directory holding the project, relative to the directory the CLI runs in. | . | GUARDRAIL_INPUT_PROJECTDIR |
How to fix
Name the package manager and the version beside it in package.json, which is what Corepack installs:
{
"packageManager": "pnpm@9.1.0"
}Without it, and with a bare name just the same, the install runs under whichever npm, pnpm or yarn the runner happens to carry, so a lock file one package manager wrote is resolved by another and the tree a developer reviewed is not the tree CI installs.
More in nodejs
nodejs/lockfile-committed. The project commits a lock file, so an install of the same commit resolves the same versions.nodejs/single-package-manager. The project commits at most one lock file, so two package managers do not each believe they own the tree.nodejs/version-declared. The project declares the Node.js version it is built and run against, and that version is no older than the configured floor.