# no-nodejs-modules

Rule `import/no-nodejs-modules`. Forbid Node.js builtin modules.

- Source: import
- Technologies: Imports
- Kind: correctness
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1658 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `import/no-nodejs-modules` | no | no | package `eslint-plugin-import` | [docs](https://github.com/import-js/eslint-plugin-import/blob/v2.32.0/docs/rules/no-nodejs-modules.md) |
| Oxlint | `import/no-nodejs-modules` | no | no | plugin `import`, category style | [docs](https://oxc.rs/docs/guide/usage/linter/rules/import/no-nodejs-modules.html) |
| Biome | `correctness/noNodejsModules` | no | no | group correctness, since 1.5.0 | [docs](https://biomejs.dev/linter/rules/no-nodejs-modules/) |

## Code examples

### Incorrect: the rule reports this

```js
import fs from 'fs';
import path from 'path';

var fs = require('fs');
var path = require('path');
```

### Correct: the rule accepts this

```js
import _ from 'lodash';
import foo from 'foo';
import foo from './foo';

var _ = require('lodash');
var foo = require('foo');
var foo = require('./foo');

/* eslint import/no-nodejs-modules: ["error", {"allow": ["path"]}] */
import path from 'path';
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import importPlugin from "eslint-plugin-import";

export default [
  {
    plugins: { import: importPlugin },
    rules: {
      "import/no-nodejs-modules": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "plugins": [
    "import"
  ],
  "rules": {
    "import/no-nodejs-modules": "error"
  }
}
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "correctness": {
        "noNodejsModules": "error"
      }
    }
  }
}
```

## Related rules

- [import/no-default-export](https://lintradar.dev/rules/import/no-default-export.md): Forbid default exports.
- [import/no-commonjs](https://lintradar.dev/rules/import/no-commonjs.md): Forbid CommonJS `require` calls and `module.exports` or `exports.*`.
- [import/exports-last](https://lintradar.dev/rules/import/exports-last.md): Ensure all exports appear after other statements.
- [import/no-unassigned-import](https://lintradar.dev/rules/import/no-unassigned-import.md): Forbid unassigned imports
- [import/group-exports](https://lintradar.dev/rules/import/group-exports.md): Prefer named exports to be grouped together in a single export declaration
- [import/max-dependencies](https://lintradar.dev/rules/import/max-dependencies.md): Enforce the maximum number of dependencies a module can have.

---

Web page: https://lintradar.dev/rules/import/no-nodejs-modules. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
