Skip to content

noNodejsModules (JavaScript)

Language JavaScript (and super languages)
biome.json
{
"linter": {
"rules": {
"correctness": {
"noNodejsModules": "error"
}
}
}
}

Forbid the use of Node.js builtin modules.

This can be useful for client-side web projects that don’t have access to those modules.

The rule doesn’t trigger if there are dependencies declared in the package.json that match the name of a built-in Node.js module.

Type-only imports are ignored.

import fs from "fs";
code-block.js:1:16 lint/correctness/noNodejsModules ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This import references a Node.js builtin module.

> 1 │ import fs from "fs";
^^^^
2 │

Node.js builtin modules are unavailable outside the Node.js runtime, so this import breaks client-side and other non-Node.js environments.

Remove this import or replace it with a runtime-agnostic alternative.

import path from "node:path";
code-block.js:1:18 lint/correctness/noNodejsModules ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

This import references a Node.js builtin module.

> 1 │ import path from "node:path";
^^^^^^^^^^^
2 │

Node.js builtin modules are unavailable outside the Node.js runtime, so this import breaks client-side and other non-Node.js environments.

Remove this import or replace it with a runtime-agnostic alternative.

import fs from "fs-custom";
import type path from "node:path";