Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 21
    Right, it's just basics of reference types. Commented Sep 26, 2013 at 10:32
  • 7
    Great explanation. The documentation for module.exports describes it too: nodejs.org/api/modules.html#modules_module_exports Commented May 1, 2019 at 4:38
  • 2
    here is documentation for exports: nodejs.org/api/modules.html#modules_exports_shortcut, which gave me another view of understanding Commented May 23, 2019 at 3:37
  • Thanks, but why we do need both exports and module.exports? Can't we just live with (i.e.) the latter, for sake of simplicity (and KISS principle)? Commented May 20, 2020 at 14:52
  • 1
    There is strictly not a need for exports, it's just a handy shorthand. But now it can never be removed because it would break all existing code. Commented May 26, 2020 at 18:32