
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.
env-validator-zero
Advanced tools
Zero-dependency schema-based environment variable validator for Node.js, React, and Vite
Zero-dependency environment variable validator with full TypeScript support for Node.js, React, and Vite.
npm install env-validator-zero
import { defineEnv, ENV } from 'env-validator-zero';
export const env = defineEnv({
API_URL: ENV.string(),
PORT: ENV.number().default(3000),
DEBUG: ENV.boolean().optional(),
});
// Fully typed
console.log(env.API_URL); // string
console.log(env.PORT); // number
console.log(env.DEBUG); // boolean | undefined
ENV.string() - String values
.optional() - Makes variable optional.default(value) - Provides fallback valueENV.number() - Numeric values (parses strings automatically)
.optional() - Makes variable optional.default(value) - Provides fallback valueENV.boolean() - Boolean values (accepts: "true", "false", "1", "0")
.optional() - Makes variable optional.default(value) - Provides fallback valueimport { defineEnv, ENV, EnvValidationError } from 'env-validator-zero';
try {
const env = defineEnv({
API_KEY: ENV.string(),
});
} catch (error) {
if (error instanceof EnvValidationError) {
console.error(error.message);
process.exit(1);
}
}
Error messages:
Missing required environment variable: API_KEYInvalid number for PORT: expected number, got "abc"import { defineEnv, ENV } from 'env-validator-zero';
export const env = defineEnv({
NODE_ENV: ENV.string().default('development'),
DATABASE_URL: ENV.string(),
PORT: ENV.number().default(3000),
ENABLE_LOGGING: ENV.boolean().default(true),
});
import { defineEnv, ENV } from 'env-validator-zero';
export const env = defineEnv({
VITE_API_URL: ENV.string(),
VITE_APP_TITLE: ENV.string().default('My App'),
VITE_ENABLE_ANALYTICS: ENV.boolean().default(false),
});
import { defineEnv, ENV } from 'env-validator-zero';
export const env = defineEnv({
NEXT_PUBLIC_API_URL: ENV.string(),
DATABASE_URL: ENV.string(),
JWT_SECRET: ENV.string(),
});
MIT 2025
FAQs
Zero-dependency schema-based environment variable validator for Node.js, React, and Vite
We found that env-validator-zero 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.