O'Reilly logo

Node Web Development - Second Edition by David Herron

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 3. Node Modules

Before writing Node applications we must learn about Node modules and packages. Modules and packages are the building blocks for breaking down your application into smaller pieces.

In this chapter we will:

  • Learn what a module is
  • Learn about the CommonJS module specification
  • Learn how Node finds modules
  • Learn about the npm package management system

So, let's get on with it.

Defining a module

Modules are the basic building blocks for constructing Node applications. A Node module encapsulates functions, hiding details inside a well protected container, and exposing an explicitly declared list of functions.

We have already seen modules in action; every JavaScript file we use in Node is itself a module. It's time to see what they are ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required