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

More Node.js tasks

Back to the full Node.js Core Modules cheat sheet