Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
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 Respuestas
Responde la pregunta

0

With NodeJS you can load an environment variable like this:

process.env.VARIABLE_NAME
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda