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

211
Views
Is there a way to load a .json configuration file and automatically substitute environment variables?

I'm a little new to the javascript ecosystem, so apologies if I'm asking the question wrong.

I'm working on a legacy project that loads configuration files from .json files. In those .json files there are variables that need to be substituted with environment variables.

For example config.json:

{
  "database": {
    "host": "%DBHOST%",
    "port": "%DBPORT%"
  }
}

In the legacy code, there are complicated startup scripts that use sed to do variable substitution. I'm moving the project into docker and would much rather define DBHOST/DBPORT etc in the docker definitions and have it magically update the configuration. Right now, I just have docker running a script that does the sed operation which works, but this feels clunky. Is there a way I can tell node to load the .json file and automatically substitute the %VAR% blocks with an environment variable if there is a match?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

With NodeJS you can load an environment variable like this:

process.env.VARIABLE_NAME
about 4 years ago · Juan Pablo Isaza 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!