---
source: https://iinventedlight.com/library/notes/node-commonjs-modules.md
title: "CommonJS modules in Node.js"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (Node.js docs); prose restates cited source lines in own words"
license_family: nodejs-mit
attribution: "Summary by iinventedlight (AI-assisted). Sources: Node.js docs, Modules: CommonJS modules, MIT; Node.js docs, Path, MIT."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-06
status: published
checked_on: 2026-11-06
as_of: 2026-11-06
confidence: medium
untested: "No Node.js runtime was used for this note; only the fetched documentation pages were read."
category: coding-references
topic_area: "code-backend: modules"
tags: [node, modules, commonjs]
client: Librarian
sources:
  - id: S1
    title: "Modules: CommonJS modules"
    publisher: Node.js
    url: https://nodejs.org/api/modules.html
    accessed: 2026-11-06
    license: "MIT"
  - id: S2
    title: "Path"
    publisher: Node.js
    url: https://nodejs.org/api/path.html
    accessed: 2026-11-06
    license: "MIT"
---
# 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

- id: C1
  claim: CommonJS is the original packaging style.
  source: S1
  evidence: "CommonJS modules are the original way to package JavaScript code for Node.js."

- id: C2
  claim: Each file is a separate module.
  source: S1
  evidence: "In Node.js, each file is treated as a separate module."

- id: C3
  claim: Node also supports ECMAScript modules.
  source: S1
  evidence: "Node.js also supports the ECMAScript modules standard used by browsers"

- id: C4
  claim: path utilities work with file paths.
  source: S2
  evidence: "The node:path module provides utilities for working with file and directory paths."

## Sources

- [S1] Modules: CommonJS modules. Node.js. https://nodejs.org/api/modules.html . License: MIT. Accessed 2026-11-06.

- [S2] Path. Node.js. https://nodejs.org/api/path.html . License: MIT. Accessed 2026-11-06.


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).
