Validate environment variables against JSON Schema using Ajv with .env file support via Node.js built-in parseEnv. Version 7.0.0, actively maintained under Fastify organization. Key differentiators: leverages Node's native parseEnv (no dotenv dependency), supports custom Ajv instances and plugins, fluent-schema API, custom keywords like separator and expandEnv. Supports ESM and CJS, ships TypeScript types.
npm install env-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Defines a JSON schema for env vars with required PORT number, loads .env, outputs validated config.
Remove dotenv dependency; .env files are now parsed using Node's parseEnv. The dotenv option still works but uses native parsing.
Use import envSchema from 'env-schema' instead of import { envSchema } from 'env-schema'Replace confKey with key in the config object
Explicitly set additionalProperties: true in schema if needed
Pass { useDefaults: true, coerceTypes: true, removeAdditional: true } when creating custom Ajv instanceUpgrade env-schema to v7 and remove dotenv from your dependencies; use Node's built-in parseEnv automatically
Use `import envSchema from 'env-schema'` (default import) or `const envSchema = require('env-schema')` for CJSEnsure the data option is an object or omit it to use process.env