2
The Module System
In Chapter 1, The Node.js Platform, we briefly introduced the importance of modules in Node.js. We discussed how modules play a fundamental role in defining some of the pillars of the Node.js philosophy and its programming experience. However, what do we mean when we talk about modules and why are they so important?
In generic terms, modules are the bricks for structuring non-trivial applications. Modules allow you to divide the code base into small units that can be developed and tested independently. Modules are also the main mechanism to enforce information hiding by keeping all the functions and variables that are not explicitly marked to be exported private. Additionally, modules make it easier to share and reuse code ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access