CodeZettaInterview Hub

Node.js · Runtime · Senior · Debugging

What are Node's module systems today?

Short Interview Answer

CommonJS (`require`/`module.exports`) and ES modules (`import`/`export`), with dual-package hazards.

Detailed Explanation

Package.json `type`, `.mjs`/`.cjs`, and conditional exports control resolution. Mixing CJS/ESM incorrectly causes 'ERR_REQUIRE_ESM' and dual instances of singleton modules — a frequent production bug.

Common Mistake

Assuming require() always works for modern ESM-only packages.

Did you know this answer?