---
title: "unicorn/prefer-node-protocol"
description: "Require the `node:` prefix when importing Node.js built-in modules"
# Generated by src/codegen/lint-rule-docs.ts. Do not edit below this line.
plugin: "unicorn"
aliases: []
kind: "suggestion"
category: "restriction"
default: "off"
fixable: "yes"
typeAware: false
deprecated: false
---

`import fs from "fs"` looks like it imports an npm package. `node:fs` makes it obvious that the module is built in.

The rule checks `import`, `export { ... } from`, `import()`, `require()` and TypeScript's `import fs = require("fs")`.

`--fix` adds the prefix.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"unicorn/prefer-node-protocol" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 4} */}
```js
import fs from "fs";
import { readFile } from "fs/promises";
export { EventEmitter } from "events";

const os = await import("os");
```

Not reported:

{/* good */}
```js
import fs from "node:fs";
import { readFile } from "node:fs/promises";
export { EventEmitter } from "node:events";

const os = await import("node:os");
```

Packages and your own files aren't reported:

{/* good */}
```js
import express from "express";
import fs from "./fs.js";
```
