React Native: Loaded "env" configuration for the "production" profile: no environment variables specified.

This is a post to describe a fix for an error in React Native, specifically an Expo Bare project, that looks like "Loaded "env" configuration for the "production" profile: no environment variables specified".

I ran into this bug trying to upgrade a client's React Native Android app. The app is built using Expo and I'm using eas to build and submit both iOS and Android apps to their app stores. After I made a code change, I started a build using eas build but after the build started I remembered I didn't was logged into Expo with the wrong user account. So I killed the build process, logged out of my Expo account, opened a new terminal and logged into the Expo CLI with the right credentials.

I ran a new eas build but the build failed with the following error:

✔ Select platform › Android
Loaded "env" configuration for the "production" profile: no environment variables specified. Learn more: https://docs.expo.dev/build-reference/variables/
You don't have the required permissions to perform this operation.

Entity not authorized: AccountEntity[ID] (viewer = RegularUserViewerContext[ID], action = READ, ruleIndex = -1) Request ID: ID Error: GraphQL request failed.

I did some Googling and found this helpful Github post which made me realize my mistake. When I started the first build using my own Expo account instead of the client's Expo account, the build process wrote a JSON property called extra.eas.projectId to the app.json file of my project. Because I didn't have a project under my Expo account that matched what I was trying to build, Expo created a new project with a new id in my account using with the value written to extra.eas.projectId. As soon as I deleted the extra property from app.json I was able to build the project successfully again.

At first I didn't think the error made any sense, but the more I thought about it you can see that "Entity not authorized" actually makes sense here - the first part about the env configuration is a little bit of a red herring though. So what happened was Expo was trying to build my project under an Expo project that the current user didn't have access to. Which makes sense now.

So, in conclusion if you run into this error, delete this property from your app.json file and do a new eas build command. The new command will create a new extra.eas.projectId with the appropriate project id and you'll be golden.

"extra": {
"eas": {
"projectId": "12345678-1234-1234-be5b-f844590a0aad"
}
}