Skip to Content
Env ValidationOverview

Env Validation

Miso automatically loads .env files into your scripts — you don’t need --env for that. The --env flag and miso env are for validation: checking that variables exist and match their expected types before running.

Usage

miso env validates environment variables from your .env files against rules defined in miso.json.

miso env

Or use --env as a flag behind other commands to validate before running:

miso dev --env miso build --env

Quick Start

  1. Add an env array to miso.json, with one entry per app or .env file:
>miso.json
{ "env": [ { "label": "web", "path": "apps/web/.env.local", "variables": { "PORT": "port", "DATABASE_URL": "url" } }, { "label": "api", "path": "apps/api/.env", "variables": { "REDIS_URL": { "type": "url", "schemes": ["redis", "rediss"] } } } ] }
  1. Run miso env before starting your app (or in CI):
miso env && miso dev

Each entry is validated independently. If a variable fails in the api entry, the error will say so:

api: missing required variable: REDIS_URL

Auto-Discovery

Even without an env block in miso.json, Miso automatically loads a .env file into every script it runs. It walks the following candidates in order and loads the first one it finds:

PriorityFile
1.env.local
2.env.production
3.env.development
4.env

Variables already set in the shell environment take precedence over values in the file — Miso never overrides a variable that is already present in the process environment.

In a monorepo, auto-discovery searches the workspace root rather than the project root when you run a workspace-scoped script.

Next Steps

  • Configure labels, paths, required variables, and validation rules
  • See the Types & VarConfig reference for all supported types and options
Last updated on