Issue
NodeJS MJS scripts cannot be started:
[ERR_REQUIRE_ESM]: Must use import to load ES Module
[ERR_REQUIRE_ESM]: require() of ES Module
Environment
- CloudLinux
- NodeJS
- Passenger
Solution
As a workaround, the following "cjs" wrapper can be used to load esm script:
# cat start.cjs
(() => import('./start.js'))();
and then this start.js(start.cjs) will run successfully.
Cause
Limitation of the passenger function because it can only load common js (cjs) scripts
Comments
0 comments
Please sign in to leave a comment.