1.0.3 • Published 5 years ago

@alucarpd86/dotenv-json v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

dotenv-json

Load environment variables via a JSON file

npm install @alucarpd86/dotenv-json

Define your environment variables in .env.json in the root of your project (or wherever you start your node process):

{
  "sample_key": "sample_value"
}

Load your environment variables at the beginning of your program:

require("dotenv-json")();

console.log(process.env.sample_key) // => sample_value

N.B. Existing keys in process.env will not be overwritten.

You can customize the location of your .env.json file by passing a path option:

const dotenvJSON = require("dotenv-json");
dotenvJSON({ path: "./config/example.json"});

You can override existing options by passing a ovverride option:

const dotenvJSON = require("dotenv-json");
dotenvJSON({ override: true});

You can monitor the file changes and reload the environment variables by passing watch option:

const dotenvJSON = require("dotenv-json");
dotenvJSON({ watch: true});
1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago