# prefer-node-protocol

Rule `node/prefer-node-protocol`. Enforce using the `node:` protocol when importing Node.js builtin modules.

- Source: node
- Technologies: Node.js
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1817 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `n/prefer-node-protocol` | no | safe | package `eslint-plugin-n` | [docs](https://github.com/eslint-community/eslint-plugin-n/blob/HEAD/docs/rules/prefer-node-protocol.md) |
| Biome | `style/useNodejsImportProtocol` | yes | unsafe | group style, since 1.5.0 | [docs](https://biomejs.dev/linter/rules/use-nodejs-import-protocol/) |

## Code examples

### Incorrect: the rule reports this

```js
import fs from "fs"

export { promises } from "fs"

const fs = require("fs")

const fs = process.getBuiltinModule("fs")
```

### Correct: the rule accepts this

```js
import fs from "node:fs"

export { promises } from "node:fs"

const fs = require("node:fs")

const fs = process.getBuiltinModule("node:fs")
```

Examples from the ESLint documentation.

## Enable it

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

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

export default [
  {
    plugins: { n },
    rules: {
      "n/prefer-node-protocol": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "useNodejsImportProtocol": "error"
      }
    }
  }
}
```

## Related rules

- [unicorn/prefer-node-protocol](https://lintradar.dev/rules/unicorn/prefer-node-protocol.md): Prefer using the `node:` protocol when importing Node.js builtin modules.
- [node/no-top-level-await](https://lintradar.dev/rules/node/no-top-level-await.md): Disallow top-level `await` in published modules
- [node/no-sync](https://lintradar.dev/rules/node/no-sync.md): Disallow synchronous methods
- [node/no-process-env](https://lintradar.dev/rules/node/no-process-env.md): Disallow the use of `process.env`
- [node/no-restricted-import](https://lintradar.dev/rules/node/no-restricted-import.md): Disallow specified modules when loaded by `import` declarations
- [node/no-restricted-require](https://lintradar.dev/rules/node/no-restricted-require.md): Disallow specified modules when loaded by `require`

---

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