node: Import Prefix in Node.js
From the Node.js Core Modules cheat sheet ยท Modern Node.js (Built-in) ยท verified Jul 2026
node: Import Prefix
Explicitly import built-in modules to avoid name collisions
javascript
// Prefer the node: prefix for built-in modules (Node 16+)
import fs from 'node:fs/promises'
import path from 'node:path'
import { createServer } from 'node:http'
import { fileURLToPath } from 'node:url'
import { setTimeout as sleep } from 'node:timers/promises'
// Why: the prefix guarantees you get the built-in, not a same-named npm
// package, and makes intent obvious to humans and tools.๐ก Prefer `node:` everywhere โ uniform and unambiguous
โก Eliminates a class of name-collision and shadowing bugs
๐ Works on Node 16+; required for `node:test` and a few newer modules
๐ฏ eslint-plugin-n has a `prefer-node-protocol` rule to enforce it
esmimportsmodern