Skip to content

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

An encrypted padlock leads to one terminal command, a turbo.json file, and a stack of tasks.
getmyenv run starts turbo. turbo.json decides which names each task gets.

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=loose

If 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 build

The 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 build

npx getmyenv run --explain lists every name and where it comes from. Never values.

Related docs: How run works, Languages, Contexts