question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Variables from multiple .env files

See original GitHub issue

Hey!

Thanks for the awesome lib!

It would be nice if env-cmd could read variables from multiple .env files. There is a common approach to use .env and .env.local, and maybe .env.<environment> (.env.production, .env.development, etc.) schema.

Here are the examples:

It’s a common and nice practice since you can use common defaults in an .env file and then override them in a machine-specific .env.local. Usually you commit .env to a git repository and do not commit .env.local (secrets go there).

Currently it looks like it’s impossible to use env-cmd in such way. It would be nice if we could by using some argument, for example:

env-cmd --cascade mocha -R spec
# or different argument name of course

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:22
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
soophiecommented, Jul 2, 2020

We fixed it in a way by using: env-cmd -f .env.staging env-cmd -f .env.staging.local --silent run-scripts build Because of silent it doesn’t matter if you have a local file, but it will be read.

2reactions
toddbluhmcommented, Jul 1, 2020

I had been thinking about this idea for a while. Probably the next major rewrite will take this approach. Not sure when that will be, but I have been needing to turn my attention back to this project for a while now. Thanks for the feature request 😄

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using multiple .env files. - Prisma
One solution is to have multiple .env files which each represent different environments. In practice this means you create a file for each...
Read more >
Loading Multiple .env Files for Different Environments in NodeJS
The most natural solution is to have two different .env files - one for each environment. Let's name the first .env.dev for the...
Read more >
Toggle between multiple .env files like .env.development with ...
When working on my vue.js projects, I can use files like .env.development or .env.production to get different values for the same env key ......
Read more >
Node JS Environment Variables — Setting Node app for ...
Configuring environment variables to a separate file rather than in our node js code enables us to run and point our app to...
Read more >
Managing multiple environment file in NodeJS - Dev Genius
My approach was to create only one . env file and write down all variable files in it.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found