1.1.1 • Published 9 years ago
node-dotenv v1.1.1
NodeJS Dot Environments
This library exports all pairs (key=value) from .env-file to process.env-object.
This makes it very easy to configure your application using the environment variables.
Install
$ npm i node-dotenvUsage
"use strict";
const dotEnv = require('node-dotenv')(); //It's enough
// or with an explicit file path
dotEnv = require('node-dotenv')('../file/path/to/.env'); //It's enough
//if you want get all vars from .env
dotEnv.then(envVars => console.log(envVars));File path to .env
.env-file search stage (places): 
- parameter passed in the call module;
- value from environment variable NODE_DOT_ENV_PATH;
- in root directory of your project;
- as a result of call - dirname(require.main.filename).
Example .env-file structure:
varName1=varVal1
varName2=varVal2
varName3=varVal3
...
varNameN=varValN
...Comments in .env
You can commented some strings of .env-file like follow: 
varName1=varVal1
#varName2=varVal2
varName3=varVal3String started with # will not be parse.
License
Licensed under the MIT License