
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
Configuration management using environment-variables, validation & object extension.
Configuration management using environment-variables, validation & object extension.
Using environment variables in node.js projects including validation, default values & type conversion.
$ npm install env-val --save
Schemas are loaded by default from all files matching **/*.js in the directory ./config.
Define a schema in ./config/logger.js.
// Load EnvVal to be able to get the exposed joi object.
const EnvVal = require('env-val');
const schema = EnvVal.joi.object({
LOGGER_LEVEL: EnvVal.joi
.string()
.valid(['error', 'warn', 'info', 'verbose', 'debug', 'silly'])
.default('info'),
LOGGER_ENABLED: EnvVal.joi
.boolean()
.truthy('TRUE')
.truthy('true')
.falsy('FALSE')
.falsy('false')
.default(true)
}).required();
const {error, value: envVars} = EnvVal
.joi
.validate(process.env, schema, {allowUnknown: true, stripUnknown: true});
if (error) {
throw new Error(`Config validation error: ${error.message}`);
}
const values = envVars;
module.exports = {
schema,
values
};
Basic initialization of env-val:
const EnvVal = require('env-val');
let configs = new EnvVal().init();
console.log(configs.LOGGER_ENABLED); // => true
console.log(configs.LOGGER_LEVEL); // => 'info'
Override environment variables:
const EnvVal = require('env-val');
let configs = new EnvVal({
LOGGER_ENABLED: false,
LOGGER_LEVEL: 'warn'
})
configs.init();
console.log(configs.LOGGER_ENABLED); // => false
console.log(configs.LOGGER_LEVEL); // => 'warn'
By default config files are loaded from the ./config directory.
This can be customized by passing the CONFIG_DIR option to the constructor of env-val.
const EnvVal = require('env-val');
const path = require('path');
let configs = new EnvVal({
CONFIG_DIR: path.join(__dirname, 'my-custom-dir`
});
Stefan Walther
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue. The process for contributing is outlined below:
I cannot guarantee that I will merge all PRs but I will evaluate them all.
MIT
This file was generated by verb-generate-readme, v0.6.0, on May 08, 2018.
FAQs
Configuration management using environment-variables, validation & object extension.
We found that env-val 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
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.