Env Validation
Miso automatically loads
.envfiles into your scripts — you don’t need--envfor that. The--envflag andmiso envare 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 envOr use --env as a flag behind other commands to validate before running:
miso dev --env
miso build --envQuick Start
- Add an
envarray tomiso.json, with one entry per app or.envfile:
{
"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"]
}
}
}
]
}- Run
miso envbefore starting your app (or in CI):
miso env && miso devEach entry is validated independently. If a variable fails in the api entry, the error will say so:
api: missing required variable: REDIS_URLAuto-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:
| Priority | File |
|---|---|
| 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