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

184
Views
make-runnable package for ESModule NodeJS

make-runnable package works only on CommonJS, and base on this rules of import-export in CommonJS and ESModule :

https://miro.medium.com/max/875/1*3cI3YvzG0HakM7VCaxtbfA.png

I can not figure how to solve this my apps.

...

I am currently work on ESModule, so I need all of my code in modules type.

Here is my code on the file who need to import .mjs file:

const students = require('../../repository/students.mjs')

function drop() {
    students.drop()
}

module.exports = {
    drop
}

require('make-runnable/custom')({
    printOutputFrame:false
})

And when I run node path/to/my/file/index.js drop, this is the error ouput:

node:internal/modules/cjs/loader:979
    throw new ERR_REQUIRE_ESM(filename, true);
    ^

Error [ERR_REQUIRE_ESM]: require() of ES Module my/path/to/api/controller.mjs not supported.
Instead change the require of my/path/to/api/controller.mjs to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (my/path/to/index.js:1:18) {
  code: 'ERR_REQUIRE_ESM'
}

Is there any chance to make make-runnable packages can be run on ESModule?

Or is there another way to run a function from CLI with ESModule?

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!