node.js – Cpanel require () problem for node js using ES module
i have been trying to deploy a Node js app built using ES module in CPANEL but whenever i run the server i get this error from require
Node.js v20.18.2
/usr/local/lsws/fcgi-bin/lsnode.js:48
var app = require(startupFile);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /home/royalsecret/server/index.js from /usr/local/lsws/fcgi-bin/lsnode.js not supported.
Instead change the require of index.js in /usr/local/lsws/fcgi-bin/lsnode.js to a dynamic import() which is available in all CommonJS modules.
at startApplication (/usr/local/lsws/fcgi-bin/lsnode.js:48:15)
at Object. (/usr/local/lsws/fcgi-bin/lsnode.js:16:1) {
code: 'ERR_REQUIRE_ESM'
}
I have been getting error 503 when i run end points, please any help will be appreciated.
Currently i have set the node version to v20.18.2 which was available to cpanel and my app node version is v22.3.0
Read more here: Source link
