Environment variables don't seem to be detected in build
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 236
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 91
Description
### Build/Submit details page URL
https://expo.dev/accounts/jorensm/projects/app/builds/3dcb9d5c-dfb2-487d-a6e5-8ce5c65b2288
### Summary
So I'm trying to add environment variables to my EAS build. I've added them in my `eas.json` file, like so:

But they don't seem to be detected in my build. I have a validator function that throws an error if the env variables are not set, and its throwing it in my builds, thought it works fine with Expo Go.
### Managed or bare?
Managed
### Environment
expo-env-info 1.2.0 environment info:
System:
OS: Windows 10 10.0.19045
Binaries:
Node: 20.8.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
SDKs:
Android SDK:
API Levels: 30, 31, 33
Build Tools: 30.0.2, 30.0.3
IDEs:
Android Studio: Version 2020.3.0.0 AI-203.7717.56.2031.7678000
npmPackages:
@expo/webpack-config: ^19.0.0 => 19.0.0
expo: ~49.0.15 => 49.0.21
expo-router: ^2.0.0 => 2.0.14
react: 18.2.0 => 18.2.0
react-dom: 18.2.0 => 18.2.0
react-native: 0.72.6 => 0.72.6
react-native-web: ~0.19.6 => 0.19.10
Expo Workflow: managed
`expo-doctor` didn't find any issues
### Error output
_No response_
### Reproducible demo or steps to reproduce from a blank project
This is the file that loads my env variables. On Expo Go it doesn't throw an error but on a EAS build it does.
```
// Constants from environment variables
const ENV_VARIABLE_NAMES = [
'API_URL',
'STRIPE_PUBLISHABLE_KEY',
'SUPABASE_URL',
'SUPABASE_KEY'
]
const validateEnvVariables = () => {
const missing_vars = []
for(const var_name of ENV_VARIABLE_NAMES) {
const full_var_name = 'EXPO_PUBLIC_' + var_name
if(!process.env[full_var_name]) {
missing_vars.push(full_var_name)
}
}
if (missing_vars.length > 0) {
throw new Error('Missing the following environment variables: ' + missing_vars.join(', '))
}
}
validateEnvVariables();
export const API_URL = process.env.EXPO_PUBLIC_API_URL!;
export const SUPABASE_URL = process.env.EXPO_PUBLIC_SUPABASE_URL!;
export const SUPABASE_KEY = process.env.EXPO_PUBLIC_SUPABASE_KEY!;
export const STRIPE_PUBLISHABLE_KEY = process.env.EXPO_PUBLIC_STRIPE_PUBLISHABLE_KEY!;
```
Contributor guide
Assessment
This issue has not been assessed yet.