[ERR_REQUIRE_ESM]: Must use import to load ES Module Print

  • 0

NodeJS applications that contain MJS scripts cannot be started and may display one of the following errors in their stderr.log:

[ERR_REQUIRE_ESM]: Must use import to load ES Module
[ERR_REQUIRE_ESM]: require() of ES Module
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: app.js

We utilize an implementation of Passenger which has the same limitations of Passenger such as it can only load common js (cjs) scripts. You can workaround this by building a "cjs" wrapper to load the esm script:

# cat start.cjs
(() => import('./start.js'))();

and then this start.js(start.cjs) will run successfully.




Was this answer helpful?

« Back

Ready to get started? Build your site from