EAS Android build environment file not found

I have setup an environment.ts file for my API and other URLs for dev, staging and prod.

This environment.ts is under .gitignore.

I followed these instructions:

Now I tried to:

eas build --platform android --profile staging

In dev mode everything works well, but when building, the environemnt.ts file is not found in e.g. our socket.ts file:

error Unable to resolve module ../environment from /home/expo/workingdir/build/lib/socket.ts

Did I miss something?

I use managed workflow, my eas-cli version is eas-cli/0.47.0 darwin-x64 node-v12.16.1.

It seems, that I may should switch to react-dotenv or does somebody see an obvious error of mine?

If you have the file in .gitignore then by default it will not be uploaded to the build server when you run eas build.

There are a few solutions.

You could create a .easignore file that is basically a copy of your .gitignore file, except without the environment.ts file. Then eas will use that instead of .gitignore to decide what to ignore.

Another option is to use environment variables or secrets for this.

See the following for more info:

See also:

Thank you very much for your input!

I tried the .easignore solution and it worked. :+1: