Node.js now supports a
node: protocol for built-in modules.
import * as fs from 'fs/promises';
import * as fs from 'node:fs/promises';
What are the benefits of using
node: module specifiers?
- It’s immediately clear that a built-in Node.js module is imported. Given how many of them there now are, that’s useful information.
- There is no risk of a module in
node_modules overriding the built-in module.
- This is especially important whenever Node.js adds a new built-in module.
- Supported in Node.js starting:
- v16.0.0, v14.18.0 (ESM
import and CommonJS
- v14.13.1, v12.20.0 (only ESM
- Supported in TypeScript by the latest versions of