Skip to content

nodeProtocols

Prefer the node: protocol prefix for Node.js built-in modules for clarity and consistency.

✅ This rule is included in the node logical preset.

The node: protocol makes it explicit that the module is a Node.js built-in, preventing confusion with npm packages that might have the same name. The protocol is supported in Node.js 16+ and is the recommended way to import built-ins.

import fs from "fs";
import path from "path";
import { readFile } from "fs";
import fsPromises from "fs/promises";
const crypto = require("crypto");

This rule is not configurable.

If you need to support Node.js versions older than 16, you should not use this rule, as the node: protocol was introduced in Node.js 16.0.0.

If you strongly prefer more succinct imports and aren’t worried about confusing userland modules with built-in Node.js modules, this rule might not be for you.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.