A runnable env environment
Gone are the days of using flat
.env files. This module will help you to build your env should you need that flexability.
Here is a simple example:
// .env.js// Set your own defaults, whatever! Its your env anyways!const env =NODE_ENV: 'develop'// Dynamically change thigns...if envNODE_ENV === 'develop'envLOGGING = true// Put all your vars into the exports!moduleexports = env
And you can now just use it as expected:
You can simply install:
npm i --save jsdotenv
And then create a
.env.js file in your root. After that include this package like you see above and you are ready to go!
You can access this simple package with a simplified example, or use some of our additional Features.
If you just wanna parse a file, try the following:
const jsdotenv =const parsed = jsdotenvconsole // will be the evaluated parsed result.
The example above is the minimalistic approach of the
config function. You can also use advanced features as well like so (defaults in parenthesis):