CommonJS

noun

say it: “KOM-un-JAY-ESS” /ˈkɑmənˌdʒeɪˌɛs/

Node's older module format, which loads code with require() and shares it with module.exports.

What is CommonJS in JavaScript?

CommonJS — The Node.js module format based on require() and module.exports.

const reports = require("./reports.js");
module.exports = reports;

In a sentence

  • “Older Node projects use CommonJS, so you'll see require("express") in their code.”
  • “A file that uses module.exports is written in CommonJS.”

Level: Freelancer · More JavaScript terms at this level

Updated