
Security News
The Changelog Podcast: Practical Steps to Stay Safe on npm
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.
default-env
Advanced tools
Composable cascading environment variable defaults.
The environments your app runs in don't divide into neat buckets like development, staging, and production. Your client side unit tests shouldn't spend time minifying. Your integration tests should. You always minify in production. Your continuous integration host doesn't install the browser that gives you nice test failure debugging in development, but sometimes you want to run those just like CI, because they fail there but pass on your machine.
Instead of coding all those configuration rules into your app, layer on additive environments. Define your environments near eachother, so the composition is easy to reason about.
Variables explicitly set in the environment always have final say.
npm install default-env
var defaultEnv = require('default-env')
defaultEnv.define({
test: {
PORT: 4001,
LOG_LEVEL: 'error',
OPTIMIZE: false
},
integration: {
OPTIMIZE: true
},
development: {
OPTIMIZE: false,
PORT: 4000,
LOG_LEVEL: 'warning'
},
production: {
OPTIMIZE: true,
LOG_LEVEL: 'verbose'
}
})
task('test:integation', function() {
defaultEnv.use('test', 'integration')
// ...
})
See tests for more examples.
Please follow our Code of Conduct when contributing to this project.
$ git clone https://github.com/goodeggs/default-env && cd default-env
$ npm install
$ npm test
Module scaffold generated by generator-goodeggs-npm.
FAQs
Composable cascading environment variable defaults
We found that default-env demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.

Security News
Ruby's creator Matz assumes control of RubyGems and Bundler repositories while former maintainers agree to step back and transfer all rights to end the dispute.