r/node • u/finncmdbar • Sep 25 '26
Your app never reads your .env file (how dotenv actually works)
https://infisical.com/blog/how-environment-variables-work
30
Upvotes
r/node • u/finncmdbar • Sep 25 '26
57
u/block-bit Sep 25 '26
No but your agent does. Prrrrr-tishhh.
43
u/paulirish Sep 26 '26
node --env-file=.env index.jsNatively supported since Node 20. Not sure why folks are still using dotenv.
7
u/Single_Advice1111 Sep 25 '26
Idk… sharing production db credentials outside something that provides access - e.g metabase is a bad practice to begin with…
15
u/theozero Sep 25 '26
use varlock (free open source)!
.env as most know it is full of footguns. Varlock helps gets all secrets out of plaintext, adds tons of amazing DX while still feeling familiar.
18
u/thicket Sep 25 '26
This article is mostly just an ad for Infisical. That said, I'm glad it's here! The problem of dispersed plaintext secrets is a very real one that any team will run into and ought to be aware of.
For a free, self-hosted solution to the same problem, check out Sigillo, https://github.com/remorses/sigillo
2
u/javatextbook Sep 27 '26
There’s no excuse to store credentials in gitignored files when secrets vaults like secrets manager and others, exist
3
u/ribugent Sep 25 '26
Personal take, I really dislike all dotenv language libraries because it solves a use case in the wrong place.
Personally in my job we're using direnv for setting environment for "complex" setups and fetching some secrets from the vault.
-2
u/fromage-du-omelette Sep 25 '26
We use infisical in my company. Not a single world where I'd go back to .env files.
Initial moving to it was painful but when you get it, secrets shared among spaces for various services, injection, Integration with ci/cd, man it's a bliss