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

99
Vistas
Import JSON field in ES6 format

I just came across this line of code:

const config = require(__dirname + '/../config/config.json')[env];

It imports one specific field from a json file, depending on an environment variable (in this case it imports different keys for testing, development and production).

What would the equivalent be in a javascript ES6 module? I am currently using this method:

import config from "../config/config.json" assert { type: "json" };
const settings = config[NODE_ENV];

Which requires importing all the settings and declaring another variable. Is there any way to import just one field?

about 4 years ago · Juan Pablo Isaza
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