Must Environment Variables be included in the eas.json file for production builds?

I have used manage workflow throughout development and have environment variables in a .env file. They are not in the .gitignore file. My last production release did not have them.

When I build, I get the message:

Loaded “env” configuration for the “production” profile: no environment variables specified.

This message is as vague as the documentation. I know how hard it is to write clear documentation so I am not throwing stones. My reading of the documentation and the message is that I can still use the .env file in a production environment for app store/play store submissions if I have not excluded it. Is that a correct assumption? The reason I ask is because for the first time my program crashes and burns when build/submitted and installed.

If in fact you must include them in the eas.json file for production builds, you should look at the way the documentation is written and clean it up.

It doesn’t say that you must include them in your eas.json file. It uses words like “might not be available.” If you don’t have them in the .gitignore are they there are are they not?

The documentation also says:
If you set variables in a .env file for local development as described in the environment variables guide, you can set those same variables in a build profile in eas.json .

That word “can” implies that it is not a “must”

The documentation then tells you to add the .env file to the .gitignore but it is not clear if you must do that.

I am running expo cli 6.3.10

Thanks in advance for your help.

that is right! you don’t need to if you don’t want to. if you have fallbacks for env vars, like const apiUrl = process.env.API_URL ?? '' then there is no need to do so. if you want those environment variables to be available on eas build, you should either commit your .env file or put them in eas.json. that said, at this point the question arises - why even use .env at all if you’re just checking it in to source control? you might as well just use a .js or .ts file to store constants and import them

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.