1.0.1 • Published 5 years ago

dotenv-jsonenv v1.0.1

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

dotenv-jsonenv

Load environment variables via a JSON file

npm install dotenv-jsonenv

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

{
    "BASE_URL": "https://google.com",
    "env": {
      "public_api_key": "s@Mpl3_d@Ta",
      "OTHER_ENV_VARS": "otherEnvVars"
    }
}

Load your environment variables at the beginning of your program:

require("dotenv-json")();

console.log(process.env.public_api_key) // => s@Mpl3_d@Ta

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-jsonenv");
dotenvJSON({ path: ".example.json"});
1.0.1

5 years ago

1.0.0

5 years ago