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

114
Views
Is there a way to include an ESM only package via require?

I have a node dependency that is included in version 2 with require. Now with version 3 the library can only be included with import.

Error [ERR_REQUIRE_ESM]: require() of ES Module

But my script uses require.

Is there a way to include an ESM only package via require?

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

0

You can use dynamic import for this purpose but it's better to use the version that supports CommonJs unless you are using ESM itself

const thePackage = import('the-package');

about 4 years ago · Juan Pablo Isaza Report

0

Yes; I've built the fix-esm library for this purpose. It works basically by transparently converting ESM exports to CJS exports.

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!