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

182
Views
Convert CJS to ES6

How can I convert these lines of code to ES6?

const basename = path.basename(__filename);
const config = require(__dirname + '/../config/config.json')[env];
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You don't need to convert anything to ES6, it's perfectly valid ES6 - it just doesn't use any new features that were introduced in ES6 from my knowledge. You could use destructuring if you really wanted to:

const { env: config } = require(__dirname + "/../config/config.json");

But ES6 is not a fancy new language, it's just got some new features you can use if you need them.

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!