CommonJS is a project to standardize themodule ecosystem forJavaScript outside ofweb browsers (e.g. onweb servers or native desktop applications).
CommonJS's specification of how modules should work is widely used today for server-side JavaScript with Node.js.[1] It is also used for browser-side JavaScript, but that code must be packaged with atranspiler since browsers don't support CommonJS.[1] The other major module specification in use is theECMAScript (ES) modules specification (ES6 modules aka ES2015 modules).[2] CommonJS can be recognized by the use of therequire() function andmodule.exports, while ES modules useimport andexport statements for similar (though not identical) functionality.
The project was started byMozilla engineer Kevin Dangoor in January, 2009 and initially namedServerJS.[3]
What I’m describing here is not a technical problem. It’s a matter of people getting together and making a decision to step forward and start building up something bigger and cooler together.
— Kevin Dangoor[3]
In August 2009, the project was renamedCommonJS to show the broader applicability of theAPIs.[4] Specifications are created and approved in an open process. A specification is only consideredfinal after it has been finished by multiple implementations.[5] CommonJS is not affiliated with theEcma International group TC39 working onECMAScript, but some members of TC39 participate in the project.[6]
The list of specifications includes:[7]
The proposals cover much more than modules. They intend to define a set of APIs that are useful both for non-web JavaScript implementations, with standardized package names to provide interoperability within the ecosystem. This goal sometimes overlaps with that of TC39, and parts such as Promises have indeed made it into ECMAScript itself.
The part after the slash is the version. When a proposal is in contention, each individual proposal (including sequential revisions from the same author) is assigned a new letter. When the main direction is known it starts being assigned numeric versions.