Cover by David Herron

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

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

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required