Failed to load ./.env

I am building a Angular web service on Render. I have added environment variables on render dashboard. My local server works well with the .env file. But I get “Failed to load ./.env.” when building with “ng build -c production --aot”. Please how do I make the app get the saved environment variables on render.

This error message suggests your application does not have a .env file in its sources, or that it is not located at whatever the working directory (./) is.

The former (no .env file) is a good thing, you shouldn’t have credentials in code / in git. Instead, configure the same environment variables with their production-appropriate value on Render directly ( Environment Variables and Secrets | Render Docs ) and then refer to the variable, without explicitly requiring the existing of the .env file.