node-js-getting-started icon indicating copy to clipboard operation
node-js-getting-started copied to clipboard

.env should not be included in source control

Open ricka opened this issue 9 years ago • 3 comments

@jonmountjoy Per the 12 factor app guidelines on configuration, there should be an explicit split between code and config. .env files should typically be included in a .gitignore and shouldn't be contained within the codebase itself.

If needed, developers can pull different environment config into their own environment with heroku config on the command line to export environment variables.

ricka avatar Sep 16 '16 16:09 ricka

You are correct, and it's not ideal the way I've done it. It's like that because this code base was written to support the tutorial, which utilizes the existing .env to make it easier for folk to start.

I don't like it though, it's promoting a bad practice I guess, so I'll set about fixing it there and elsewhere sometime in the future. Thanks!

jonmountjoy avatar Sep 20 '16 09:09 jonmountjoy

It looks like the first place it is used or mentioned is on this page. Perhaps just changing the instructions to create the file? Better yet (in my opinion) would be to show how to first create the environment variables on heroku and then show how to copy down those environment variables with heroku config -s > .env. Just a thought.

ricka avatar Sep 20 '16 13:09 ricka

An alternative is to supply a .env.example file with placeholders and instructing the users to rename it to .env during the tutorial.

aalaap avatar Feb 28 '21 10:02 aalaap

Yes, We can add .env.example file, I will do those changes. Thanks

kunal8411 avatar Mar 31 '23 12:03 kunal8411