CommonJS
CommonJS is a module specification for JavaScript that defines a standard for organizing and loading code modules in server-side environments, primarily Node.js. It enables developers to structure applications into reusable files using `require()` to import modules and `module.exports` or `exports` to export functionality. This system addresses JavaScript's historical lack of a built-in module system, facilitating code organization and dependency management.
Developers should learn CommonJS when working with Node.js applications, as it is the default module system in Node.js for many years, making it essential for backend development, tooling, and legacy projects. It is particularly useful for server-side scripting, building command-line tools, and managing dependencies in environments where ES modules are not yet supported or require transpilation. Understanding CommonJS is crucial for maintaining and migrating older Node.js codebases.