CommonJS and ESM
Older Node code uses CommonJS (require/module.exports). Modern Node supports ES modules (import/export). Know both when reading docs.
- "type": "module" in package.json enables ESM.
- require is sync; ESM is static and tree-shake friendly.
- Stick to one style per project.
const message = "cjs-or-esm";
console.log(message);
After you read this chapter, use Write (when available) and Quiz on this page to lock it in.