no-nodejs-modules
Disallow importing Node.js built-ins via the node: protocol.
Targeted pattern scopeโ
This rule checks import/export source strings across:
import ... from "..."export ... from "..."export * from "..."- dynamic
import("...")
By default it disallows sources matching node:*.
What this rule reportsโ
This rule reports source strings that match "node:*".
Why this rule existsโ
Some codebases standardize on unprefixed built-in specifiers (fs, path) for
compatibility or stylistic consistency. This rule enforces that policy.
โ Incorrectโ
import fs from "node:fs";
โ Correctโ
import fs from "fs";
Behavior and migration notesโ
This rule reports only and does not provide an autofix.
Migration is generally mechanical: replace node:fs with fs, node:path
with path, and so on.
Optionsโ
type Options = {
allow?: string[];
disallow?: string[];
};
Default:
{
"disallow": ["node:*"]
}
Additional examplesโ
export { readFile } from "node:fs/promises";
// โ reported by default
const fsModule = await import("fs");
// โ
valid with default settings
ESLint flat config exampleโ
import etcMisc from "eslint-plugin-etc-misc";
export default [
{
plugins: { "etc-misc": etcMisc },
rules: {
"etc-misc/no-nodejs-modules": "error",
},
},
];
When not to use itโ
Disable this rule if your codebase intentionally requires node:-prefixed imports.
Package documentationโ
Rule catalog ID: R034
Further readingโ
Adoption resourcesโ
- Start at warning level in CI, then move to error after cleanup.
- Use focused codemods/autofix batches per package or directory.