r/learnjavascript • u/Strict_Historian_106 • Apr 02 '26
How do you handle out-of-sync .env files in monorepos?
I’ve been struggling with the classic "app crashes because of a missing key in .env.local" issue. It’s even worse in monorepos with dozens of environment files.
I scripted a small CLI to scan directories and find missing keys between templates and local files (handling .env.example, .local, .test, etc.) without ever reading the secret values.
It’s been working great for my team, so I made it open-source. How do you guys solve this? Git hooks, CI checks, or just manual pain?
If you want to roast my approach, you can test it instantly: npx env-parity analyze
Feedback on the recursive scanning logic is more than welcome!
2
u/showmethething Apr 02 '26
Like the idea but your solution is required because you did things wrong at the start, you shouldn't have multiple env files.
There are valid reasons to sometimes, but this is probably not one of them
1
u/Patch1897 Apr 03 '26
.env files should never be pushed to a repo.
5
u/azhder Apr 02 '26
Read this https://12factor.net/config
Having multiple .env files is not a good thing. You should strive to have a single
.envthat is ignored by git and…Maybe put a
.env.examplethat will help people learn the meaning of the variables and give them a quick start with some sane defaults.0
u/[deleted] Apr 02 '26
[deleted] — view deleted comment