Skip to content

Prefer using the node: protocol when importing Node.js builtin modules ​

💼 This rule is enabled in the ✅ recommended config.

🔧 This rule is automatically fixable by the --fix CLI option.

When importing 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.

Fail ​

js
import dgram from 'dgram';
js
export {strict as default} from 'assert';
js
import fs from 'fs/promises';

Pass ​

js
import dgram from 'node:dgram';
js
export {strict as default} from 'node:assert';
js
import fs from 'node:fs/promises';
js
import _ from 'lodash';
js
import fs from './fs.js';

Released under the Apache License 2.0.