Dotenv: How to use different environments

Created on 2 Jun 2020  Â·  5Comments  Â·  Source: motdotla/dotenv

I want to use some npm packages in a symfony app where I use different environments (local dev, staging, live, ...). It seems that your package only reads the .env file, but not .env.local and other .env files for different environments.

The .env-File is like a template to configurate. I copy it in the environment. .env is managed via git, but not the other .env-Files like .env.local

Most helpful comment

I recently learned about https://www.npmjs.com/package/dotenv-flow, which might address some people's needs.

All 5 comments

I came here to ask exactly this. The readme says what not to do, but offers no clear guidance (that I saw) on what ought to be done instead.

Perhaps this section can be expanded...?
https://github.com/motdotla/dotenv#should-i-have-multiple-env-files

This is possibly a duplicate of https://github.com/motdotla/dotenv/issues/437

It's a very common and practical approach to use .env, .env.local, etc. Here are the examples:

This statement — https://github.com/motdotla/dotenv#should-i-have-multiple-env-files — is really confusing and looks more like a dogma.

I recently learned about https://www.npmjs.com/package/dotenv-flow, which might address some people's needs.

I would recommend using dotenv flow! Its a great package and uses this package at its core. Sorry for the dogmatic phrasing in the README, the opinions in the readme have not been updated for a while. There have been lots of discussions about that one part of the readme. Closing this issue for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Quocnamit picture Quocnamit  Â·  3Comments

AndersDJohnson picture AndersDJohnson  Â·  4Comments

shai32 picture shai32  Â·  5Comments

AndrewChen1982 picture AndrewChen1982  Â·  4Comments

shellscape picture shellscape  Â·  3Comments