npm

Join us for the upcoming webinar, "Enterprise JavaScript done right: the tools you love, the security you need."Sign up here »

@alucarpd86/dotenv-json

1.0.3 • Public • Published

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});

install

npm i @alucarpd86/dotenv-json

Downloadsweekly downloads

1

version

1.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability