Chapter Index
The Module System
5 topics in this chapter
5Topics
01
Topic
CJS require() Internals
How Node.js require works internally through resolution, Module._load, source wrapping, compilation, module.exports, and require.cache.
nodejsmodulesrequireCommonJSmodule-cache
28 min read
02Topic
Module Resolution
How Node.js resolves module specifiers through built-ins, relative paths, node_modules lookup, package.json main, exports, imports, and symlinks.
nodejsmodulesresolutionnode_modulespackage-exports
30 min read
03Topic
ES Modules
How ES Modules work in Node.js through static import/export syntax, module format detection, parse-link-evaluate phases, and live bindings.
nodejsmodulesESMimportexportstatic-analysis
30 min read
04Topic
CommonJS/ESM Interop
How CommonJS and ES Modules interoperate in Node.js through CJS namespaces, require(esm), conditional exports, and dual package design.
nodejsmodulesCJS-ESM-interopdual-packagesconditional-exports
34 min read
05Topic
import.meta & ESM Caching
How import.meta, import.meta.url, import.meta.dirname, the ESM module cache, circular dependencies, and module state work in Node.js.
nodejsmodulesimport-metamodule-cachecircular-dependencies
27 min read