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

283
Views
Nextjs importing a commonjs module (@theatrejs/core) that depends on a ES module (lodash-es) is causing [ERR_REQUIRE_ESM]

As explained in the title, I created a fresh Nextjs project (v12), installed @theatrejs/core npm package, upon import the package and using it in the code my build started showing errors, more specifically:

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/projects/nextjs-xtxeun/node_modules/lodash-es/get.js
require() of ES modules is not supported.
require() of /home/projects/nextjs-xtxeun/node_modules/lodash-es/get.js from /home/projects/nextjs-xtxeun/node_modules/@theatre/dataverse/dist/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename get.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/projects/nextjs-xtxeun/node_modules/lodash-es/package.json

In a nutshell, nextjs 12 app -> @theatrejs/core (commonjs) -> lodash-es (ESM).

you can see a reproduction of the error here: https://stackblitz.com/edit/nextjs-xtxeun

Can anyone point me toward a way to make it work?

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!