With the recent release of version 20.6.0, Node.js now has built-in support for .env files. You can now load environment variables from a .env file into...
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.
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.