Chapter 6: Creating and Using Node.js Modules
Modules are at the heart of Node.js. They correspond to JavaScript files and can be used in our applications. A program for the Node.js server will consist of a set of modules, that is, JavaScript files.
There are three kinds of modules:
- Modules that we write ourselves for our applications.
- Modules internal to Node.js and usable directly.
- Modules that can be downloaded from the internet using a utility called npm (npm stands for Node.js package manager). This npm utility is installed with Node.js itself.
In this chapter, we will learn how to create and use these different types of modules.
Regardless of the type of modules used, the require(moduleName) instruction (see below) allows the module ...
Get JavaScript from Frontend to Backend 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.