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

97
Views
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
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!