Version 16.25.x stopped recognising local .env variables
- Dominant language
- TypeScript
- Stars
- 1.4k
- Forks
- 236
- Avg merge
- 3d 1h
- Merged PRs (30d)
- 91
Description
### Build/Submit details page URL
_No response_
### Summary
In my `app.config.ts` I'm using ENV variables (defined locally using a `.env` file) like this:
`const bareURL = process.env.EXPO_PUBLIC_APP_BASE_URL!.replace('https://', '');`
It's been working correctly up until (and including) `eas-cli` version 16.24.1. However, on version 16.25.1 I'm getting a crash:
```
npx eas-cli@16.25.1 build -e production -p android --auto-submit -m 'deploy script test'
★ eas-cli@16.26.0 is now available.
To upgrade, run:
npm install -g eas-cli
Proceeding with outdated version.
Failed to read the app config from the project using "npx expo config" command: npx expo config --json exited with non-zero code: 1.
Falling back to the version of "@expo/config" shipped with the EAS CLI.
Error reading Expo config at /Users/sharnik/Code/brains-and-beards/dreaming-spanish/DreamingSpanishMobile/app.config.ts:
Cannot read properties of undefined (reading 'replace')
Error: build command failed.
error Command failed with exit code 1.
```
If I run `npx expo config` manually, it does not crash.
My bet is that the handling of environment variables have changed between version 16.24.x and 16.25.x.
### Managed or bare?
Managed
### Environment
```
expo-env-info 2.0.7 environment info:
System:
OS: macOS 15.6.1
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.17.0 - ~/.asdf/installs/nodejs/20.17.0/bin/node
Yarn: 1.22.22 - /opt/homebrew/bin/yarn
npm: 10.8.2 - ~/.asdf/plugins/nodejs/shims/npm
Watchman: 2025.05.26.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.16.2 - /Users/sharnik/.asdf/shims/pod
SDKs:
iOS SDK:
Platforms: DriverKit 24.5, iOS 18.5, macOS 15.5, tvOS 18.5, visionOS 2.5, watchOS 11.5
Android SDK:
API Levels: 30, 31, 33, 34, 35
Build Tools: 29.0.2, 30.0.2, 30.0.3, 31.0.0, 33.0.0, 33.0.1, 34.0.0, 35.0.0
System Images: android-34 | Google APIs ARM 64 v8a
IDEs:
Android Studio: 2023.1 AI-231.9392.1.2311.11330709
Xcode: 16.4/16F6 - /usr/bin/xcodebuild
npmPackages:
expo: ~53.0.20 => 53.0.20
react: 19.0.0 => 19.0.0
react-native: 0.79.5 => 0.79.5
Expo Workflow: bare
```
```
env: load .env
env: export EXPO_PUBLIC_ENV_NAME EXPO_PUBLIC_BUNDLE_ID EXPO_PUBLIC_APP_ICON_IOS EXPO_PUBLIC_APP_ICON_ANDROID_FG EXPO_PUBLIC_APP_NAME EXPO_PUBLIC_APP_BASE_URL
15/17 checks passed. 2 checks failed. Possible issues detected:
Use the --verbose flag to see more details about passed checks.
✖ Validate packages against React Native Directory package metadata
The following issues were found when validating your dependencies against React Native Directory:
Unsupported on New Architecture: react-native-fast-image
Untested on New Architecture: @kesha-antonov/react-native-background-downloader, react-native-bouncy-checkbox
Unmaintained: @gorhom/portal, react-native-fast-image, redux-persist
No metadata available: @bottom-tabs/react-navigation, @config-plugins/react-native-google-cast, @grapp/wave, @somesoap/react-native-image-palette, effect, events, queue, react-native-circular-progress-indicator, react-native-vector-icons, seedrandom, text-encoding, ts-pattern
Advice:
Use libraries that are actively maintained and support the New Architecture. Find alternative libraries with https://reactnative.directory.
Add packages to expo.doctor.reactNativeDirectoryCheck.exclude in package.json to selectively skip validations, if the warning is not relevant.
Update React Native Directory to include metadata for unknown packages. Alternatively, set expo.doctor.reactNativeDirectoryCheck.listUnknownPackages in package.json to false to skip warnings about packages with no metadata, if the warning is not relevant.
✖ Check that packages match versions required by installed Expo SDK
The following packages should be updated for best compatibility with the installed expo version:
expo@53.0.20 - expected version: ~53.0.23
expo-navigation-bar@4.2.7 - expected version: ~4.2.8
react-native@0.79.5 - expected version: 0.79.6
jest-expo@53.0.9 - expected version: ~53.0.10
Your project may not work correctly until you install the expected versions of the packages.
Found outdated dependencies
Advice:
Use 'npx expo install --check' to review and upgrade your dependencies.
To ignore specific packages, add them to "expo.install.exclude" in package.json. Learn more: https://expo.fyi/dependency-validation
2 checks failed, indicating possible issues with the project.
```
### Error output
```
EXPO_DEBUG=true yarn deploy:prod:android -m "deploy script test"
yarn run v1.22.22
$ npx eas-cli@16.25.1 build -e production -p android --auto-submit -m 'deploy script test'
★ eas-cli@16.26.0 is now available.
To upgrade, run:
npm install -g eas-cli
Proceeding with outdated version.
Failed to read the app config from the project using "npx expo config" command: npx expo config --json exited with non-zero code: 1.
Falling back to the version of "@expo/config" shipped with the EAS CLI.
Error reading Expo config at /Users/sharnik/Code/brains-and-beards/dreaming-spanish/DreamingSpanishMobile/app.config.ts:
Cannot read properties of undefined (reading 'replace')
TypeError: Error reading Expo config at /Users/sharnik/Code/brains-and-beards/dreaming-spanish/DreamingSpanishMobile/app.config.ts:
Cannot read properties of undefined (reading 'replace')
at Object. (/Users/sharnik/Code/brains-and-beards/dreaming-spanish/DreamingSpanishMobile/app.config.ts:10:66)
at Module._compile (node:internal/modules/cjs/loader:1469:14)
at requireFromString (/Users/sharnik/.npm/_npx/b3d78fdb42ac56dc/node_modules/require-from-string/index.js:28:4)
at evalConfig (/Users/sharnik/.npm/_npx/b3d78fdb42ac56dc/node_modules/@expo/config/build/evalConfig.js:68:47)
at readConfigFile (/Users/sharnik/.npm/_npx/b3d78fdb42ac56dc/node_modules/@expo/config/build/getConfig.js:45:41)
at getDynamicConfig (/Users/sharnik/.npm/_npx/b3d78fdb42ac56dc/node_modules/@expo/config/build/getConfig.js:54:18)
at getConfig (/Users/sharnik/.npm/_npx/b3d78fdb42ac56dc/node_modules/@expo/config/build/Config.js:280:43)
at getExpoConfigInternalAsync (/Users/sharnik/.npm/_npx/b3d78fdb42ac56dc/node_modules/eas-cli/build/project/expoConfig.js:49:46)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async getPrivateExpoConfigAsync (/Users/sharnik/.npm/_npx/b3d78fdb42ac56dc/node_modules/eas-cli/build/project/expoConfig.js:89:12) {
isConfigError: true
}
Error: build command failed.
error Command failed with exit code 1.
```
### Reproducible demo or steps to reproduce from a blank project
`const bareURL = process.env.EXPO_PUBLIC_APP_BASE_URL!.replace('https://', '');`
Contributor guide
Assessment
This issue has not been assessed yet.