# What is a module in Node.js ?

Published 2022-12-03

This tutorial explains to you what is a module in Node.js. You will see also the difference between a module and a package.

Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient. Node.js is build on small modules included in packages. A package is frequently referred to as a module since, usually it has one single module as an entry point. This modularity makes Node.js to have a small core. Node.js runs on various platforms (Windows, Linux, Unix, Mac OS X, etc.)

Node.js uses asynchronous programming => when a task is sent to the server the Node.js is not waiting for the response and can handle another request immediately. This great improvement is one of the strongest feature of Node.js.

A Node.js Module is a library of functions that could be used in Node.js. These modules are generally small and include functionalities related to a domain. For the list of Node.js modules, you can go here.

There are 3 module type in Node.js:

  • Built-in modules (provided by Node.js installation)
  • User-defined modules (created by the user)
  • Third party modules (generally available on the Internet)

A package is one or more modules (libraries) grouped (or packaged) together.

Because of its architecture Node.js is used to develop I/O intensive web applications like video streaming sites, single-page applications, and other web applications.