prefer-node-protocol

March 27, 2026 ยท View on GitHub

๐Ÿ“ Prefer using the node: protocol when importing Node.js builtin modules.

๐Ÿ’ผ This rule is enabled in the following configs: โœ… recommended, โ˜‘๏ธ unopinionated.

๐Ÿ”ง This rule is automatically fixable by the --fix CLI option.

When getting builtin modules, it's better to use the node: protocol as it makes it perfectly clear that the package is a Node.js builtin module.

Examples

// โŒ
import dgram from 'dgram';

// โœ…
import dgram from 'node:dgram';
// โŒ
export {strict as default} from 'assert';

// โœ…
export {strict as default} from 'node:assert';
// โŒ
import fs from 'fs/promises';

// โœ…
import fs from 'node:fs/promises';
// โŒ
const fs = require('fs/promises');

// โœ…
const fs = require('node:fs/promises');
// โŒ
const fs = process.getBuiltinModule('fs/promises');

// โœ…
const fs = process.getBuiltinModule('node:fs/promises');
// โŒ
type Fs = import('fs');

// โœ…
type Fs = import('node:fs');