Parse and load environment files (containing ENV variable exports) into Node.js environment, i.e. process.env
.
Example
.env
# some env variables FOO=foo1 BAR=bar1 BAZ=1 QUX= # QUUX=
.env2
# some env variables using exports syntax exports FOO=foo2 exports BAR=bar2 exports BAZ=2 exports QUX= # exports QUUX=
index.js
var assert = ; var env = ; processenvFOO = "defaultfoo"; // Load any undefined ENV variables form a specified file. ; assert; assert; assert; assert; assert; // Load another ENV file - and overwrite any defined ENV variables. ; assert; assert; assert; assert; assert;
API
-
(filepath)
; -
(filepath, options)
;
Installation
$ npm install node-env-file
Test
Local tests:
$ make test
Examples
Local examples:
$ make example
Related Libraries
License
Released under the MIT license.
Copyright (c) Jonas Grimfelt