concept

CommonJS

CommonJS is a module specification for JavaScript that defines a standard for organizing code into reusable modules, primarily used in server-side environments like Node.js. It provides a synchronous module loading system where modules are loaded using the `require()` function and exported with `module.exports` or `exports`. This specification enables developers to structure large applications by breaking them into manageable, interdependent files.

Also known as: Common JS, CommonJS Modules, CJS, Node.js Modules, require()
🧊Why learn CommonJS?

Developers should learn CommonJS when working with Node.js, as it is the default module system for Node.js applications, allowing for modular code organization and dependency management. It is essential for building server-side applications, tools, and scripts where synchronous loading is acceptable, and it facilitates code reuse and maintainability in non-browser environments.

Compare CommonJS

Learning Resources

Related Tools

Alternatives to CommonJS