npm dotnv code example
Example 1: dotenv npm
//In CMD
npm i dotenv
//in JS file
require('dotenv').config();
Example 2: node dotenv
require('dotenv').config();
console.log(process.env.MY_ENV_VAR);
Example 3: .env
npm install dotenv
//In CMD
npm i dotenv
//in JS file
require('dotenv').config();
require('dotenv').config();
console.log(process.env.MY_ENV_VAR);
npm install dotenv