require-node-version-file
Require a .node-version file in Node.js projects.
Targeted pattern scopeâ
This rule checks the repository root for .node-version.
What this rule reportsâ
This rule reports when .node-version is missing from the repository root.
Why this rule existsâ
Different Node.js versions can silently change runtime behaviour. Without a pinned
version file, developers, CI runners, and containerised builds may each use a
different Node.js version, leading to hard-to-reproduce bugs. .node-version is
widely supported by version managers and CI setup tooling.
â Incorrectâ
// .node-version is missing from the repository root
â Correctâ
// .node-version contains the pinned version
20.11.1
ESLint flat config exampleâ
import repoPlugin from "eslint-plugin-repo";
export default [
repoPlugin.configs.node,
{
plugins: { "repo-compliance": repoPlugin },
rules: {
"repo-compliance/require-node-version-file": "warn",
},
},
];
When not to use itâ
Disable this rule if your project intentionally standardizes on .nvmrc only and
you enforce that in a separate check (for example
require-nvmrc-file).
Rule catalog ID: R039