So I've just installed Expo SDK51: "expo": "~51.0.8",
and want to build something. But I have a weird error or bug that I only see the "Welcome to Expo" large text with a prompt to create a file in "app" dir. Although this should not occus since when I look up for the text it is nowhere in the files and the app dir already has the basic tab bar files with parallax. I have never seen this occur and I have no idea how to get out of this.
Yes I have tried clean run, yes I've tried restarting and so on... this is just weird.
Did your project use react-native-dotenv
or any other env Babel plugins? According to the Expo SDK 51 changelog:
react-native-dotenv is not compatible with expo-router. If you are using the
react-native-dotenv
Babel plugin, it will overwriteexpo-router
configuration environment variables and you'll see the empty state "Welcome to Expo" screen. We are tracking the incomptibility in expo/expo#28933, but we recommend removing the library and Babel plugin, and instead using Expo CLI's built-in support for .env files (learn more).
I had the problem when I upgraded my project from Expo SDK 49 to Expo SDK 51, so I erased module:react-native-dotenv
from babel.config.js and removed the library, but it turned out I also had babel-plugin-transform-inline-environment-variables
, so I had to remove that too. After refactoring to use Expo environment variables, my project worked fine.
Hope this helps :)
So I had the same issue but solved it, this way following the steps below:
npm uninstall react-native-dotenv
Copy and paste the code below in your babel.config.js
:
module.exports = function (api) {
api.cache(true);
return {
presets: ['babel-preset-expo']
};
};
Access all your environment variables like this process.env.X e.g. GOOGLE_API_KEY, make sure to use process.env.X everywhere in your application
Then run this command: npx expo start -c
to start your expo app and it will work just fine
You can read here for more knowledge: https://docs.expo.dev/guides/environment-variables/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With