← All notes

CommonJS modules in Node.js

CommonJS modules are the original way to package JavaScript code for Node.js. [S1]

Files as modules

In Node.js, each file is treated as a separate module. [S1]

Node.js also supports the ECMAScript modules standard used by browsers. [S1]

Paths beside modules

The node:path module provides utilities for working with file and directory paths. [S2]

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Copyright Node.js contributors. MIT (https://github.com/nodejs/node/blob/main/LICENSE).

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Node.js docs, Modules: CommonJS modules, MIT; Node.js docs, Path, MIT.

Cite this

Permanent ID: iil:note:8n1h6pzm

iinventedlight. 2026. "CommonJS modules in Node.js." iinventedlight Library, iil:note:8n1h6pzm, version of 2026-11-06. https://iinventedlight.com/library/notes/node-commonjs-modules/. License: CC-BY-4.0.

@misc{iil_note_8n1h6pzm,
  author = {{iinventedlight}},
  title = {{CommonJS modules in Node.js}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-06},
  url = {https://iinventedlight.com/library/notes/node-commonjs-modules/},
  note = {Permanent ID iil:note:8n1h6pzm. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com.

For language models and agents: start at /llms.txt. This page in Markdown: /library/notes/node-commonjs-modules.md.