Chapter 3: Understanding module.exports and exports in Node.js
by James Hibbard
In programming, modules are self-contained units of functionality, which can be shared and reused across projects. They make our lives as developers easier, as we can use them to augment our applications with functionality that we haven’t had to write ourselves. They also allow us to organize and decouple our code, leading to applications that are easier to understand, debug and maintain.
In this guide, I’ll examine how to work with modules in Node.js, focusing on on how to export and consume them.
Different Module Formats
As JavaScript originally had no concept of modules, a variety of competing formats have emerged over time. Here’s a list of the main ones to be ...
Get Your First Week With Node.js, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.