Loading
The original way Node.js lets files share code with each other using require() — like passing a book between classmates.
A module system where files export values via module.exports and import them with require(). CommonJS modules load synchronously and are evaluated once, with the result cached. It is the default module system in Node.js when type: 'module' is not set.
CJS modules wrap source in a function (module, exports, require, __filename, __dirname) and execute synchronously on first require(). The module cache (require.cache) stores evaluated modules by resolved filename. Circular dependencies resolve to the partially evaluated exports object at the time of the cycle. CJS cannot statically analyze imports, preventing tree-shaking — a key motivation for ESM adoption.