DEV Community

Discussion on: Please don't commit .env

Collapse
 
gidsg profile image
Gideon Goldberg

Why have it in your git directory at all? Most frameworks let you override the config location so set it to ~/.app-name/.env or similar. If you need to provide an example dummy config you can check in an .env.sample file.

Collapse
 
somedood profile image
Basti Ortiz

Yes, that's true. At least for me, I think it's just easier to have a .env file because it requires minimal setup and messing around with global configurations.

At least in Node.js, all you have to do is npm install and require the dotenv package. Then in your code, just invoke the dotenv.config() and it should all be running smoothly via the process.env object. This way just saves you from the little extra effort you have to do with the nitty-gritty configurations.

But to each its own. Whatever workflow works the best for you, you should apply it, not because everyone does it but because you feel productive with it.