For using it in node first you have to have:
-
Installed the node-dotenv package. You can do it just by running
npm install dotenv --save
.
For a .env
file like this:
require('dotenv').config(".env");
const DB_NAME = process.env.DB_NAME
console.log(DB_NAME);