dotenvx run --validate

Validate .env file(s) against .env.example.

Use .env.example to declare the environment variables your command requires and validate .env file(s) before it runs.

# .env.example
DATABASE_URL=
API_KEY=
SENTRY_DSN= # optional
$ dotenvx run --validate -- node index.js
[VALIDATION_FAILED] missing required (DATABASE_URL, API_KEY). fix: [https://github.com/dotenvx/dotenvx/issues/907]

Validation errors are reported without stopping your command. Combine --validate with --strict to exit with code 1 before the command runs.

$ dotenvx run --validate --strict -- node index.js

Any inline comment containing the word optional marks that key as optional.

SENTRY_DSN= # optional
LOG_LEVEL=info # this value is optional

If .env.example is missing, dotenvx reports MISSING_ENV_EXAMPLE. An empty .env.example is valid and declares no required variables.