Advertisements

Nodejs create env file

Advertisements

Nodejs create env file

install npm package dotenv

Create .env file in the root folder of project, create some variables.

MY_VAR1="value1"
MY_VAR2="value2"

Use variables

require('dotenv').config();

console.log(process.env.MY_VAR1);

click for more Nodejs codes