envdotjson

    1.2.0 • Public • Published

    ENVDOTJSON

    ENVDOTJSON is a module loads environment variable from a single json file into process.env.

    Note: this module cannot be used in the browser.

    Installation

    $ npm i envdotjson

    Usage

    Require envdotjson as early as possible in your app, and load the environment variables

    require('envdotjson').load();

    Create a env.json file in your root directory, with the following format

    {
      "default": {
        "PORT": "3000",
        "DB_NAME": "user"
      }
    }

    NOTE: variables in default will gets loaded in any environment stages

    BUT, you can overwrite it in any environment stage

    {
      "default": {
        "PORT": "3000",
        "DB_NAME": "user"
      },
      "tst": {
        "DB_NAME": "user-test"
      }
    }

    In order to get process.env.DB_NAME === "user-test", you need to set the NODE_ENV=tst first, for example:

    $ NODE_ENV=tst node index.js

    set the NODE_ENV in your env.json file will not work.

    License

    MIT

    Install

    npm i envdotjson

    DownloadsWeekly Downloads

    4

    Version

    1.2.0

    License

    MIT

    Unpacked Size

    3.98 kB

    Total Files

    5

    Last publish

    Collaborators

    • lazebear