Nitro Powered Motorcycles

    @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

    0

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    6.85 kB

    Total Files

    6

    Last publish

    Collaborators

    • matteo.bruni