1.0.3 • Published 7 years ago
@alucarpd86/dotenv-json v1.0.3
dotenv-json
Load environment variables via a JSON file
npm install @alucarpd86/dotenv-jsonDefine 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_valueN.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});