Turborepo strict env mode and getmyenv
Turborepo strict mode hides variables not declared in turbo.json. Declare the names, then start turbo with npx getmyenv run.
Oct 10, 2026 · 4 min read

1. The symptom
A variable is set, but a task reads undefined. Strict mode is the default: tasks only get the names declared in turbo.json. To confirm, run once in loose mode:
npx getmyenv run -- turbo run build --env-mode=looseIf the task works now, declare the names and go back to strict.
2. Declare the names
List names, never values. npx getmyenv ls prints the names in your project.
json{ "globalEnv": ["DATABASE_URL"], "tasks": { "build": { "env": ["STRIPE_SECRET_KEY", "API_*"] }, "dev": { "passThroughEnv": ["OPENAI_API_KEY"], "cache": false, "persistent": true } } }
Wildcards work. Turborepo adds NEXT_PUBLIC_* and VITE_* to env on its own in Next.js and Vite packages.
3. Wrap turbo
Run it once, from the folder linked to the project, usually the repo root.
npx getmyenv run -- turbo run dev
npx getmyenv run production -- turbo run buildThe process that run starts gets readable values as environment variables, and so do its child processes. export writes them to a plaintext file. Turborepo does not load .env files, and run does not either.
4. Cache keys
Values of names in env and globalEnv are part of the task hash. A build with another context, or a changed value, misses the cache and runs again. Names in passThroughEnv and globalPassThroughEnv reach the task without changing the hash. Use those only for values that do not change the output.
npx getmyenv run production --explain -- turbo run buildnpx getmyenv run --explain lists every name and where it comes from. Never values.
Related docs: How run works, Languages, Contexts