module.exports
Defines what a CommonJS module exposes to other files when they require it. Can export any value.
Syntax
nodejs
module.exports = value;
module.exports = { key: value };Example
nodejs
// math.js
function add(a, b) { return a + b; }
const PI = 3.14159;
module.exports = { add, PI };
// In another file:
const { add, PI } = require("./math");
console.log(add(2, 3)); // 5