Skip to content

[ERR_REQUIRE_ESM]: Must use import to load ES Module

Node.js applications that use ES Modules (.mjs or "type": "module") 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

Our hosting uses Passenger, which can only load CommonJS (CJS) scripts as the application entry point.

Create a CJS wrapper file (e.g., start.cjs) that dynamically imports your ES Module:

(() => import('./start.js'))();

Then set start.cjs as your application startup file in the Setup Node.js App interface.