O'Reilly logo

Node Web Development 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 shall:

  • 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.

What's a module?

Modules are the basic building block of constructing Node applications. We have already seen modules i n action; every JavaScript file we use in Node is itself a module. It's time to see what they are and how they work.

In the ls.js example in Chapter 2, Setting up Node, we wrote the following code to pull in the fs module, giving us access ...

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