Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

455
Views
How do you load environment variables from .env and .env.local with dotenv?

This might look like a newbie question, but I am unable to find the way to load environment variables from both .env and .env.local files in node with dotenv.

Is it even possible? How do people load environment variables from both files nowadays if not with dotenv?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Quoting from dotenv's npm page

Should I have multiple .env files?

No. We strongly recommend against having a "main" .env file and an "environment" .env file like .env.test. Your config should vary between deploys, and you should not be sharing values between environments.'

But to use .env.local or .env.test or any other environment.. one at a time is

require('dotenv').config({ path: `.env.${process.env.NODE_ENV}` })

If you still want to do it refer to dotenv-flow at https://www.npmjs.com/package/dotenv-flow

dotenv-flow comes with the feature of overwriting variables at environments.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!