Skip to Content
JavaScript Cookbook, 3rd Edition
book

JavaScript Cookbook, 3rd Edition

by Adam D. Scott, Matthew MacDonald, Shelley Powers
July 2021
Intermediate to advanced
535 pages
11h 55m
English
O'Reilly Media, Inc.
Content preview from JavaScript Cookbook, 3rd Edition

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 more familiar ...

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.
Start your free trial

You might also like

Learning JavaScript, 3rd Edition

Learning JavaScript, 3rd Edition

Ethan Brown
JavaScript

JavaScript

T. J. Crowder

Publisher Resources

ISBN: 9781492055747Errata PageSupplemental Content