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-dotenv
Usage
"use strict"; const dotEnv = ; //It's enough // or with an explicit file pathdotEnv = '../file/path/to/.env'; //It's enough //if you want get all vars from .envdotEnv;
.env
File path to .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)
.
.env
-file structure:
Example varName1=varVal1
varName2=varVal2
varName3=varVal3
...
varNameN=varValN
...
.env
Comments in You can commented some strings of .env
-file like follow:
varName1=varVal1
#varName2=varVal2
varName3=varVal3
String started with #
will not be parse.
License
Licensed under the MIT License