Install:
npm install dotenv --save
For example, we can store the sensitive information or env related information in a 'veriables.env' file:
// variables.envNODE_ENV=developmentDATABASE=mongodb://xxxxxMAIL_USER=xxMAIL_PASS=xxMAIL_HOST=xxx.ioMAIL_PORT=2525PORT=7777MAP_KEY=xxxxSECRET=xxxKEY=xxx
Then we can use dotenv to load those configurations:
// import environmental variables from our variables.env filerequire('dotenv').config({ path: 'variables.env' });
Now all the env related information will be stored in:
process.env