Node.js version is declared
nodejs/version-declared@v1
The project declares the Node.js version it is built and run against, and that version is no older than the configured floor.
| Id | nodejs/version-declared |
| Version | v1 |
| Category | nodejs |
| Default severity | warning |
| Interpreter | python3 |
| Timeout | 30 seconds |
| Violations tolerated | 0 |
| Collects | nodejs |
Collectors
This guardrail doesn't gather anything itself. It relies on the collectors below, which the CLI runs once per build before any check, and reads what they found from GUARDRAIL_FACTS. If a collector collects nothing, this guardrail is skipped, not failed.
| 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 inputs, passed straight through to the collector. Setting one in buildnote.json changes what is collected, and two guardrails configured the same way share a single collection.
Configuration
{
"guardrails": {
"failOn": "error",
"checks": [
{
"use": "nodejs/version-declared@v1",
"severity": "warning",
"with": {
"projectDir": ".",
"minVersion": "18"
},
"exemptions": []
}
]
}
}Inputs
| Input | Description | Default | Environment variable |
|---|---|---|---|
projectDir | Directory holding the project, relative to the directory the CLI runs in. | . | GUARDRAIL_INPUT_PROJECTDIR |
minVersion | Oldest Node.js version accepted. A declared version below this is a violation. | 18 | GUARDRAIL_INPUT_MINVERSION |
How to fix
Declare the runtime where the project already describes itself: "engines": { "node": ">=20" } in package.json, or an .nvmrc file naming the exact release. Without one, the runtime is whatever the runner happens to have, so a syntax or standard library difference shows up in CI instead of on the laptop where it was introduced.
More in nodejs
nodejs/lockfile-committed. The project commits a lock file, so an install of the same commit resolves the same versions.nodejs/package-manager-pinned. The manifest names the package manager and the exact version Corepack should install.nodejs/single-package-manager. The project commits at most one lock file, so two package managers don't both try to manage the dependency tree.