Symptoms
When deploying a Node JS Application, you are faced with an error resembling the following:
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/user/app-path/app.js from /opt/cpanel/ea-ruby27/root/usr/share/passenger/helper-scripts/node-loader.js not supported.
Instead change the require of app.js in /opt/cpanel/ea-ruby27/root/usr/share/passenger/helper-scripts/node-loader.js to a dynamic import() which is available in all CommonJS modules.
Description
This error can occur when deploying an application that relies on older modules, and requires some additional configuration to increase compatibility.
Workaround
- Access the account via SSH as the cPanel or root user
- Navigate to the path that holds the main *.js file for the application. From the error example, this would be:
/home/user/app-path/
- Run the following command to create a Common JS module file:
cat "(() => import('./start.js'))();" > start.cjs
Comments
0 comments
Article is closed for comments.