Skip to main content

Node module.exports and exports

Node gives us a shorthand variable reference called "exports", which references "module.exports". "exports" is just a reference to "module.exports". exports === module.exports.

What is this module.exports anyway? Under the hood, something like the below happens behind the scene when we create a module:

//function (module) {
// var exports = module.exports = {};

<-- Your code in the middle -->

// return module.exports;


var require = function(path) {
  // ...
  return module.exports;


Understanding module exports