
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A zero-dependency environment configuration and validation library for Node.js. It provides a clear and explicit schema-based API for reading and validating environment variables, with support for nested config objects, default values, strict mode, and optional .env loading.
Lightweight .env loader.
loadEnv({
path?: string; // default: '.env'
override?: boolean; // default: false
ignoreMissing?: boolean; // default: true
forgiving?: boolean; // default: true
encoding?: BufferEncoding;
});
Validates environment variables and returns a fully typed config object.
defineConfig(tree, {
strict?: boolean; // reject unknown env vars
source?: Record<string, string | undefined>; // custom env source
formatError?: (issues) => Error; // custom error formatter
});
Creates a schema builder for the given environment variable.
schema("NAME").string();
schema("PORT").number();
schema("DEBUG").boolean();
schema("MODE").enum(["dev", "prod"]);
schema("LIST").array();
schema("JSON").json();
schema("CUSTOM").custom(fn);
.required()
.optional()
.default(value)
.description(text)
.minLength(n)
.maxLength(n)
.pattern(regex)
.trim()
.min(n)
.max(n)
.int()
.positive()
.negative()
.of(schema("X").number())
EnvValidationError contains all collected validation errors.
try {
defineConfig(...);
} catch (err) {
console.error(err.issues);
}
.env loader (optional)npm install envus
import { loadEnv, defineConfig, schema } from "envus";
loadEnv(); // optional
const config = defineConfig({
app: {
name: "MyService",
port: schema("PORT").number().min(1000).max(9999).default(3000),
debug: schema("DEBUG").boolean().default(false),
},
security: {
apiKey: schema("API_KEY").string().minLength(10).required(),
},
cache: {
ttl: schema("CACHE_TTL").number().positive().default(3600),
},
features: {
admins: schema("ADMINS").array().default(["root"]),
}
});
```ts
import { loadEnv, defineConfig, schema } from "envus";
// Optional: load .env file
loadEnv();
const config = defineConfig({
app: {
name: "MyService",
port: schema("PORT").number().default(3000),
},
db: {
url: schema("DB_URL").string().required(),
pool: schema("DB_POOL").number().default(5),
}
});
console.log(config.app.port);
schema("KEY").string();
schema("KEY").number();
schema("KEY").boolean();
schema("KEY").enum(["dev", "prod"]);
schema("KEY").array();
schema("KEY").json();
schema("KEY").custom(raw => parseInt(raw || "0"));
.required()
.optional()
.default(value)
.description(text)
const config = defineConfig(schemaTree, {
strict: true // throws if extra env vars are present
});
loadEnv({ path: ".env.local", override: false });
Works alongside external dotenv loaders:
import "dotenv/config";
Errors are aggregated and thrown as EnvValidationError.
try {
defineConfig({...});
} catch (err) {
console.error(err);
}
envus v2.0.0 is a complete rewrite of the library. The old API:
validateEnv()resolveEnv()has been removed, as the new schema-based system provides a more robust and type-safe configuration workflow.
If you rely on the old behavior, you can install the legacy version:
npm install envus@1.0.0-a
schema("KEY")defineConfig().env loader with loadEnv()FAQs
A zero-dependency schema system for clean, reliable env configs.
We found that envus demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.