Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Configure and optimize Turborepo monorepo build pipelines with correct task structure, caching, and CI setup.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/environment/modes.md
1# Environment Modes23Turborepo supports different modes for handling environment variables during task execution.45## Strict Mode (Default)67Only explicitly configured variables are available to tasks.89**Behavior:**1011- Tasks only see vars listed in `env`, `globalEnv`, `passThroughEnv`, or `globalPassThroughEnv`12- Unlisted vars are filtered out13- Tasks fail if they require unlisted variables1415**Benefits:**1617- Guarantees cache correctness18- Prevents accidental dependencies on system vars19- Reproducible builds across machines2021```bash22# Explicit (though it's the default)23turbo run build --env-mode=strict24```2526## Loose Mode2728All system environment variables are available to tasks.2930```bash31turbo run build --env-mode=loose32```3334**Behavior:**3536- Every system env var is passed through37- Only vars in `env`/`globalEnv` affect the hash38- Other vars are available but NOT hashed3940**Risks:**4142- Cache may restore incorrect results if unhashed vars changed43- "Works on my machine" bugs44- CI vs local environment mismatches4546**Use case:** Migrating legacy projects or debugging strict mode issues.4748## Framework Inference (Automatic)4950Turborepo automatically detects frameworks and includes their conventional env vars.5152### Inferred Variables by Framework5354| Framework | Pattern |55| ---------------- | ------------------- |56| Next.js | `NEXT_PUBLIC_*` |57| Vite | `VITE_*` |58| Create React App | `REACT_APP_*` |59| Gatsby | `GATSBY_*` |60| Nuxt | `NUXT_*`, `NITRO_*` |61| Expo | `EXPO_PUBLIC_*` |62| Astro | `PUBLIC_*` |63| SvelteKit | `PUBLIC_*` |64| Remix | `REMIX_*` |65| Redwood | `REDWOOD_ENV_*` |66| Sanity | `SANITY_STUDIO_*` |67| Solid | `VITE_*` |6869### Disabling Framework Inference7071Globally via CLI:7273```bash74turbo run build --framework-inference=false75```7677Or exclude specific patterns in config:7879```json80{81"tasks": {82"build": {83"env": ["!NEXT_PUBLIC_*"]84}85}86}87```8889### Why Disable?9091- You want explicit control over all env vars92- Framework vars shouldn't bust the cache (e.g., analytics IDs)93- Debugging unexpected cache misses9495## Checking Environment Mode9697Use `--dry` to see which vars affect each task:9899```bash100turbo run build --dry=json | jq '.tasks[].environmentVariables'101```102