Chapter 18. Node Modules
One of the great aspects of writing Node.js applications is the built-in modularity the environment provides. Itâs simple to download and install any number of Node modules, and using them is equally simple: just include a single require()
statement naming the module, and youâre off and running.
The ease with which the modules can be incorporated is one of the benefits of JavaScript modularization. Modularizing ensures that external functionality is created in such a way that it isnât dependent on other external functionality, a concept known as loose coupling. This means I can use a Foo
module, without having to include a Bar
module, because Foo
is tightly dependent on having Bar
included.
JavaScript modularization is both a discipline and a contract. The discipline comes in having to follow certain mandated criteria in order for external code to participate in the module system. The contract is between you, me, and other JavaScript developers: weâre following an agreed-on path when we produce (or consume) external functionality in a module system, and we all have expectations based on the module system.
Note
One major dependency on virtually all aspects of application and library management and publication is the use of Git, a source control system, and GitHub, an extremely popular Git endpoint. How Git works and using Git with GitHub are beyond the scope of this book. I recommend the Git Pocket Guide by Richard Silverman (OâReilly) to get ...
Get JavaScript Cookbook, 3rd 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.