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');