this post was submitted on 05 Sep 2023
14 points (100.0% liked)

JavaScript

1982 readers
1 users here now

founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 2 points 1 year ago (1 children)

This is a nice feature to add, but how do you use .env files effectively? They aren’t supposed to be checked in to Git. At runtime or on the CI you have better ways to set environment variables. I don’t understand the use case.

[–] [email protected] 6 points 1 year ago

They are most useful during local development. It’s useful to have project-scoped config that your app interacts with in a manner identical to how it works in prod.

Generally you don’t commit to version control because you want to keep secrets out of there. However, it can be sometimes useful to hold non-sensitive config that you may want to commit but also to customize on prod. For instance like NODE_ENV, so you’re not building multiple mechanisms for configuring your code. But this is less useful and generally solved with a sample config that is copied to the .env file that is never pushed to VC.