VOOZH about

URL: https://www.geeksforgeeks.org/node-js/node-js-third-party-module/

⇱ Node.js Third-Party Modules - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Node.js Third-Party Modules

Last Updated : 14 Apr, 2026

Third-party modules are external libraries installed via npm that extend Node.js functionality, such as handling HTTP requests and other complex tasks.

  • Not included by default in Node.js and must be installed manually.
  • Installed and managed using npm, which handles dependencies and updates.
  • Provide ready-made solutions for routing, authentication, database integration, and other backend tasks.

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".

πŸ‘ Screenshot-2026-03-03-113003

This command installs 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 .

When you start running your server on port no 3000 you will see output Hello Martin!

Output:

πŸ‘ Screenshot-2026-03-03-113133

Popular Third-Party Modules

Here are some widely adopted third-party modules:

1. Express

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

Output:

πŸ‘ Screenshot-2026-03-03-113535

2. 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

Output:

πŸ‘ Screenshot-2026-03-03-113940

You can check the data in the database ie. username , user id, user age etc.

πŸ‘ Screenshot-2026-03-03-114337

3. Axios

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

Output:

πŸ‘ Screenshot-2026-03-03-114812

4. lodash

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


Output:

πŸ‘ Screenshot-2026-03-03-115008

5. dotenv

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

filename: dotenv.js

Output:

πŸ‘ Screenshot-2026-03-03-115343

Note: You should have .env file in the same folder have Port no . i.e PORT= 4000

6. 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.

filename: fsappend.js


Installation : To install nodemon you need to run this command.

πŸ‘ Screenshot-2026-03-03-120018

To run the command using nodemon

πŸ‘ Screenshot-2026-03-03-121003

7. Jsonwebtoken

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

Output:

πŸ‘ json

Usage of Third-Party Modules

Third-party modules enhance application functionality by providing reliable, pre-built solutions for common development needs.

  • Time Efficiency: Saves development time by eliminating the need to build common features from scratch.
  • Community Support: Popular open source modules are actively maintained with regular improvements and bug fixes.
  • Scalability & Reusability: Promotes modular code that is easier to scale and maintain.
  • Security Updates: Well-maintained modules provide regular patches for known vulnerabilities.

Best Practices

Follow these practices to ensure efficient, secure, and maintainable use of 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 Unnecessary Dependencies: Use only essential modules to avoid clutter and maintenance issues.
  • Review Documentation Thoroughly: It helps to understand the module's API and integration patterns before implementation.
Comment
Article Tags:
Article Tags:

Explore