Chapter 8: Using ES2015 and CommonJS Modules

The previous chapter explained how npm can be used to find and install packages containing multiple JavaScript files, or modules. In this chapter, we’ll examine how modules are used in Node.js.

Skip Ahead?

The information in this chapter is important, since you’ll encounter issues with older Node.js packages. However, all the packages referenced in this course have been tested for compatibility, so you can skip ahead and return when you eventually run into a problem!

Modules provide a way to define functionality in one file and use it in another. Developers often create encapsulated code libraries responsible for handling related tasks. The benefits include:

  • code can be split into smaller files ...

Get Node.js: Novice to Ninja 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.