src/content/docs/linter/rules/no-nodejs-modules.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v1.5.0` - Diagnostic Category: [`lint/correctness/noNodejsModules`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**warning**](/reference/diagnostics#warning). - Sources: - Same as [`import/no-nodejs-modules`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-nodejs-modules.md){
"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 also isn't triggered 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";
import path from "node:path";
import fs from "fs-custom";
import type path from "node:path";