Thursday, November 6, 2025
HomeNode.jsNode.js Modules

Node.js Modules

Published on

spot_img

What is a Module in Node.js?

A module is a way of grouping related functions or data in one or more JavaScript files in Node. js. Modules can be used again in different parts of a Node. js application without affecting other modules or the global scope. Each module has its own environment, so it is isolated from other modules.

Node.js has a number of built-in modules which we can use without any further installation. Here are some of the built-in modules:

  1. assert
  2. buffer
  3. child_process
  4. crypto
  5. domain
  6. stream
  7. path
  8. os
  9. http
  10. https

You can find more modules here: https://nodejs.org/api/modules.html

How to include Modules?

To include a module in node.js file, we use the require() function with the name of the module:

JavaScript
var http = require('http');

After including a module, we can apply it in our application. This is an example of using the http module that we imported.

JavaScript
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/html'});
  res.end('Hello World!');
}).listen(8080);

Kids Learning Corner

Maths Addition Worksheets For Class 2

2 Digit Addition Worksheet Welcome to our 2-Digit Addition Worksheets page. Here you will find a...

Latest articles

Maths Addition Worksheets For Class 2

2 Digit Addition Worksheet Welcome to our 2-Digit Addition Worksheets page. Here you will find a...

Mastering AWS CDK: Essential Commands, Examples, and Resources for Cloud Infrastructure as Code

Unlock the power of AWS CDK with our comprehensive guide! Learn essential commands, explore practical examples, and discover valuable resources to streamline your cloud infrastructure development. Dive into the world of infrastructure as code and take your AWS projects to the next level.

Convert javascript multi-level object keys into snake_case

You can use a recursive approach to convert all keys of a multi-level object...

How to get an MySQL root user password in AWS Lightsail

I have recorded an video to help you on lightsail server. In this video...

More like this

Convert javascript multi-level object keys into snake_case

You can use a recursive approach to convert all keys of a multi-level object...

Node.js Get Started

Download & Install Node.js Follow official Node.js guide for Node.js installation on your environment: https://nodejs.org Getting...

Introduction to Node.js

Introduction Node.js is an open source, cross-platform runtime environment and library that is used for...