0.0.1 • Published 6 years ago

json-dotenv v0.0.1

Weekly downloads
36
License
MIT
Repository
github
Last release
6 years ago

json-dotenv

NPM Version

npm i --save json-dotenv

Usage

Create an .env.json file at the root.

{
    "EXAMPLE_NAME" : "json-dotenv",
    "EXAMPLE_PORT" : 3343,
    "EXAMPLE_VERS" : 1.3011,
    "EXAMPLE_LIST" : [
        1,
        2,
        3
    ],
    "EXAMPLE_OBJS" : {
        "first" : 1,
        "second" : 2,
        "third" : {
            "a" : 1,
            "b" : 2,
            "c" : {
                "c_a" : 31,
                "c_b" : 32,
                "c_c" : 33
            }
        }
    },    
    "npm_config_git" : "filtered"
}

Set the variables into process.env.

require('json-dotenv')(); // require('json-dotenv')('.env.json');

console.log(process.env.EXAMPLE_NAME || '');
console.log(process.env.npm_config_git); // 'git'

Assigning a property on process.env will implicitly convert the value to a string.

console.log(JSON.parse(process.env.EXAMPLE_OBJS));

License

MIT

0.0.1

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago