CHAPTER 06

The Module System

Every subchapter in this chapter, free to read online. Work through them in order, or jump straight to the runtime detail you need.

06
chapter
5
subchapters
Free
online
01
Subchapter

CJS require() Internals

How Node.js require works internally through resolution, Module._load, source wrapping, compilation, module.exports, and require.cache.

02
Subchapter

Module Resolution

How Node.js resolves module specifiers through built-ins, relative paths, node_modules lookup, package.json main, exports, imports, and symlinks.

03
Subchapter

ES Modules

How ES Modules work in Node.js through static import/export syntax, module format detection, parse-link-evaluate phases, and live bindings.

04
Subchapter

CommonJS/ESM Interop

How CommonJS and ES Modules interoperate in Node.js through CJS namespaces, require(esm), conditional exports, and dual package design.

05
Subchapter

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.

Other chapters

13 more