Interview frequency: …
Short answer
It clearly identifies a module as built in, prevents dependency confusion, and speeds up module resolution.
Explanation
Using node: resolves directly to a module included in the Node.js core rather than searching node_modules, improving security and import speed.
Code example
import fs from "node:fs/promises";Common mistakes
- Confusing external packages with built-in modules by omitting the official prefix.
Follow-up questions
- How do you use Node.js's built-in test runner (node:test) without external libraries?
- What is the difference between npm install and npm ci, and why is package-lock.json important?