I was just wondering if there was any standardized convention for .env
environment variable files. If I had multiple setups (e.g. development
, staging
, production
), what should they be titled?
I've seen:
.env.development
, ...development.env
, ...settings.development.env
, ....env
, .env.staging
, .env.production
, ...If there isn't a standard, are there arguments for which to use (kinda like ""
vs ''
for strings in JS)? Which do you use and why?
Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit.
In Microsoft Windows, each environment variable's default value is stored in the Windows Registry or set in the AUTOEXEC. BAT file.
What is a . env file? A . env file or dotenv file is a simple text configuration file for controlling your Applications environment constants. Between Local, Staging and Production environments, the majority of your Application will not change.
There is only one standard in node ecosystem - use production
in NODE_ENV
variable for production. It's used by different tools for optimizing.
The rest is on you. But personally, I don't see reasons to make it complex. If you need to differentiate instances further than just production
, development
, you can use other environment variables.
Also you need to be careful when using different NODE_ENV
for staging and production. Because the main purpose of staging is to test everything as close to production as possible. So changing NODE_ENV
can be a reason to production fail.
I'm using this convention since I can't find any other suggestions: https://rubyonjets.com/docs/env-files/
.env
.env.development
.env.test
.env.production
I like maintaining the .env at the front and this seems reasonable to me.
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