In this article, we would like to show you how to use and execute packages installed with npm in Node.js.
1. Install example npm package
npm install dotenv
This command is going to install the package in the local node_modules folder.
2. After you install a package using npm, you need to import it inside your project.
const dotenv = require('dotenv');
3. Now you can work with the variable you assigned the package to.
const dotenv = require('dotenv'); // example usage of the npm package dotenv.config();