Home >> Tutorials >> Node.js Core Modules

Node.js Modules

  • Node.js modules are useful to move the common functionalities to separate .js file to reuse it in applications based on our requirements.
  • Each module has its own context, so if we create any new module that won’t interfere with other modules in application.
Type of Modules in Node Js
  1. Core (Built-in) Modules
  2. Local (Custom) Modules
  3. Third Party (External) Modules
Core Modules: (Built-In Modules)

Node Js Core Modules comes with it's Intallation by default. You can use them as per application requirments

Load and Use Core Module with Example:

First you need to import core module using require() function.

// import node.js built-in http module
const http = require('http');

var server = http.createServer(function(req, res){
	console.log("Congrats!, Node Js is running on Port 3000");
});

server.listen(3000); 
Node.js - Utility Modules

There are many utility modules available in Node.js module library which are most frequently being used in node js project.

Module Description
OS Module

Provides basic operating-system related utility functions.

var os = require("os")
Path Module

Provides utilities for handling and transforming file paths.

var path = require("path")
Net Module

Provides both servers and clients as streams. Acts as a network wrapper.

var net = require("net")
DNS Module

Provides functions to do actual DNS lookup as well as to use underlying operating system name resolution functionalities.

var dns = require("dns")
Domain Module

Provides ways to handle multiple different I/O operations as a single group.

var domain = require("domain")
Full Stack Tutorials

Author @FullStackTutorials | View all Articles