.agents/skills/turborepo/references/environment/modes.md
Turborepo supports different modes for handling environment variables during task execution.
Only explicitly configured variables are available to tasks.
Behavior:
env, globalEnv, passThroughEnv, or globalPassThroughEnvBenefits:
# Explicit (though it's the default)
turbo run build --env-mode=strict
All system environment variables are available to tasks.
turbo run build --env-mode=loose
Behavior:
env/globalEnv affect the hashRisks:
Use case: Migrating legacy projects or debugging strict mode issues.
Turborepo automatically detects frameworks and includes their conventional env vars.
| Framework | Pattern |
|---|---|
| Next.js | NEXT_PUBLIC_* |
| Vite | VITE_* |
| Create React App | REACT_APP_* |
| Gatsby | GATSBY_* |
| Nuxt | NUXT_*, NITRO_* |
| Expo | EXPO_PUBLIC_* |
| Astro | PUBLIC_* |
| SvelteKit | PUBLIC_* |
| Remix | REMIX_* |
| Redwood | REDWOOD_ENV_* |
| Sanity | SANITY_STUDIO_* |
| Solid | VITE_* |
Globally via CLI:
turbo run build --framework-inference=false
Or exclude specific patterns in config:
{
"tasks": {
"build": {
"env": ["!NEXT_PUBLIC_*"]
}
}
}
Use --dry to see which vars affect each task:
turbo run build --dry=json | jq '.tasks[].environmentVariables'