Node.js Third Party Module
Last Updated :
23 Jul, 2025
Third-party modules are external libraries maintained and built by the developer community. Unlike core modules that are added with Node.js, these modules must be installed separately using npm. They are designed to make your complex tasks easier & modify application capabilities and make development easier.
From routing and authentication to data validation and HTTP requests, third-party modules cover nearly every aspect of modern backend development.
Installing and Using Third-Party Modules
Node.js uses npm, the world’s largest software registry, to manage third-party packages. To install A module is straightforward; you just need to give the command `npm install express`
express installation
This command installs all the popular express
web framework and adds it to the project's node_modules
directory. To use the installed module you just simply need to give the `require` command .
app.js
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Hello Mahima!');
});
app.listen(3000, () => console.log('Server running on port 3000'));
When you start running your server on port no 3000 you will see output Hello Mahima!
Output:
outputPopular Third-Party Modules
Here are some widely adopted third-party modules and their use cases:
Module | Purpose |
---|
express | fast , minimalist web framework for building APIs and web apps |
---|
mongoose | MongoDB ODM for schema-based data modeling |
---|
axios | Promise-based HTTP client for server and browser |
---|
lodash | Utility functions for working with arrays, objects etc |
---|
dotenv | Loads environment variables from a .env file |
---|
jsonwebtoken | Implementation of JSON Web Tokens (JWT) for authentication |
---|
Express - Web Framework
Express is a fast, minimalist web framework for Node.js that simplifies the process of building web applications and APIs. It provides robust routing, middleware support, and HTTP utility methods.
filename: express.js
app.js
const express= require('express');
const app= express();
app.get('/',(req,res)=>{
res.send('Hello from Express')
});
app.listen(8080,()=>{
console.log('app created successfully');
})
Output:
express jsUse Case : Build APIs and Web Servers Quickly.
Mongoose
Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js. It provides a straightforward way to define schemas and interact with MongoDB using JavaScript objects.
filename:index.js
index.js
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost:27017/testDB');
const userSchema = new mongoose.Schema({
name: String,
age: Number
});
const User = mongoose.model('User', userSchema);
const newUser = new User({ name: 'Alice', age: 25 });
newUser.save().then(() => console.log('User saved!'));
Output:
output
You can check the data in the database ie. username , user id, user age etc
databaseAxios
Axios is a promise-based HTTP client for Node.js and the browser. It simplifies making HTTP requests, handling responses, and managing errors.
filename: axios.js
axios.js
const axios = require('axios');
axios.get('https://jsonplaceholder.typicode.com/posts/1')
.then(response => {
console.log(response.data);
})
.catch(error => {
console.error(error);
});
Output:
axioslodash - Utiity Library
Lodash is a utility library that provides helpful functions for manipulating arrays, objects, strings, and more—making JavaScript code cleaner and more readable.
filename: lodash.js
lodash.js
const _ = require('lodash');
const numbers = [10, 5, 8, 3];
const sorted = _.sortBy(numbers);
console.log(sorted); // [3, 5, 8, 10]
Output:
outputdotenv
dotenv is a zero-dependency module that loads environment variables from a .env
file into process.env
. It helps manage configuration settings securely and separately from code.
filename: .env
.env
filename: dotenvx.js
app.js
require('dotenv').config();
console.log(process.env.PORT); // 4000
Output:
dotenv
Note: You should have .env file in the same folder have Port no . i.e PORT= 4000
Nodemon
Nodemon is a development utility that automatically restarts your Node.js Application whenever file change. It is very useful during development to avoid manually stopping and restarting the server after every change.
Installation : To install nodemon you need to run this command.
nodemon - installationSyntax : To run the command using nodemon
file run using nodemonJsonwebtoken
Jsonwebtoken (or jwt
) is a module that enables you to generate and verify JSON Web Tokens, commonly used for implementing secure authentication in APIs.
filename : jsonwebtoken.js
jsonwebtoken.js
const jwt = require('jsonwebtoken');
const token = jwt.sign({ username: 'Mahima_Bhardwaj' }, 'secretKey');
console.log('JWT:', token);
const decoded = jwt.verify(token, 'secretKey');
console.log('Decoded:', decoded);
Output:
jsonwebtokenWhy Use Third-Party Modules?
- Time Efficiency- They free developers to concentrate on the essential business logic by removing the requirement to create common functionality from the ground up.
- Community Support- The majority of well-liked module are open source and upheld by vibrant communities, guaranteeing constant enhancements and bug patches.
- Scalability and Reusability- It allows a clean, modular code structure that is simpler to grow and maintain.
- Security Updates- Patches for known vulnerabilties are frequently released by its well-maintained modules, which helps to create safer applications.
Best Practices When Using Third-Party Modules
- Evaluate Module Quality: It checks all the download stats, github activity, and issue resolution trends.
- Keeps Dependencies Up to Date: It uses tools like
npm outdated
or npm-check-updates
to manage updates. - Conduct Regular Security Audits: It runs
npm audit
regularly to identify and fix known vulnerabilities. - Limit Unneccessary Dependencies: It includes only Important modules . Using excessive dependencies can flood your project and introduce maintenance challenges.
- Review Documentation Thoroughly: It helps to understand the module's API and integration patterns before implementation.
Conclusion
- They are Important to the Node.js ecosystem.
- They allow developers to build scalable, effective and maintainable applications.
- They uses best practices to ensure secured and optimized integration of these modules.
- They allows long-term project stability and performance.
Similar Reads
REST API Introduction REST API stands for REpresentational State Transfer API. It is a type of API (Application Programming Interface) that allows communication between different systems over the internet. REST APIs work by sending requests and receiving responses, typically in JSON format, between the client and server.
7 min read
NodeJS Interview Questions and Answers NodeJS is one of the most popular runtime environments, known for its efficiency, scalability, and ability to handle asynchronous operations. It is built on Chromeâs V8 JavaScript engine for executing JavaScript code outside of a browser. It is extensively used by top companies such as LinkedIn, Net
15+ min read
Node.js Tutorial Node.js is a powerful, open-source, and cross-platform JavaScript runtime environment built on Chrome's V8 engine. It allows you to run JavaScript code outside the browser, making it ideal for building scalable server-side and networking applications.JavaScript was mainly used for frontend developme
4 min read
Express.js Tutorial Express.js is a minimal and flexible Node.js web application framework that provides a list of features for building web and mobile applications easily. It simplifies the development of server-side applications by offering an easy-to-use API for routing, middleware, and HTTP utilities.Built on Node.
4 min read
How to Update Node.js and NPM to the Latest Version (2025) Updating Node.js and NPM to the latest version ensures the newest features, performance improvements, and security updates. This article will guide you through the steps to update Node.js and npm to the latest version on various operating systems, including Windows, macOS, and Linux.Different Method
3 min read
How to Download and Install Node.js and NPM NodeJS and NPM (Node Package Manager) are essential tools for modern web development. NodeJS is the runtime environment for JavaScript that allows you to run JavaScript outside the browser, while NPM is the package manager that helps manage libraries and code packages in your projects.To run a Node.
3 min read
Top 50+ ExpressJS Interview Questions and Answers ExpressJS is a fast, unopinionated, and minimalist web framework for NodeJS, widely used for building scalable and efficient server-side applications. It simplifies the development of APIs and web applications by providing powerful features like middleware support, routing, and template engines.In t
15+ min read
NodeJS Introduction NodeJS is a runtime environment for executing JavaScript outside the browser, built on the V8 JavaScript engine. It enables server-side development, supports asynchronous, event-driven programming, and efficiently handles scalable network applications. NodeJS is single-threaded, utilizing an event l
5 min read
Web Server and Its Types A web server is a system either software, hardware, or both that stores, processes, and delivers web content to users over the Internet using the HTTP or HTTPS protocol. When a userâs browser sends a request (like visiting a website), the web server responds by delivering the appropriate resources,
8 min read
Steps to Create an Express.js Application Creating an Express.js application involves several steps that guide you through setting up a basic server to handle complex routes and middleware. Express.js is a minimal and flexible Node.js web application framework that provides a robust set of features for web and mobile applications. Hereâs a
10 min read