• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

Issue Problems running NODE

DaniloVaron

New Pleskian
Server operating system version
AlmaLinux 9.2
Plesk version and microupdate number
Plesk Obsidian 18.0.56
I have problems uploading a web page with node

First I got this error

/usr/share/passenger/helper-scripts/node-loader.js:80
return originalRequire.apply(this, arguments);
^

Error [ERR_REQUIRE_ESM]: require() of ES Module /var/www/vhosts/deunacolombia.com/desarrollo.deunacolombia.com/deunacolombia-node/index.js from /usr/share/passenger/helper-scripts/node-loader.js not supported.
Instead change the require of index.js in /usr/share/passenger/helper-scripts/node-loader.js to a dynamic import() which is available in all CommonJS modules.
at Module.require (/usr/share/passenger/helper-scripts/node-loader.js:80:25)
at loadApplication (/usr/share/passenger/helper-scripts/node-loader.js:243:2)
at setupEnvironment (/usr/share/passenger/helper-scripts/node-loader.js:214:2)
at Object.<anonymous> (/usr/share/passenger/helper-scripts/node-loader.js:133:1) {
code: 'ERR_REQUIRE_ESM'
}

I tried a workaround from the same forum by creating an index.cjs file containing

import('./index.js').then(() => console.log('@@@@@@@ WORKED')).catch(e => console.log('@@@@@ @@ FAILED', e.message, e.stack));

making sure that the executable was that file.

1697122415811.png

Now the page has a 504 error

1697122487073.png
I use .ejs as templates and the page views are located here...
1697122609748.png

Does anyone have a solution please

Thanks
 
I have problems uploading a web page with node

First I got this error

/usr/share/passenger/helper-scripts/node-loader.js:80
return originalRequire.apply(this, arguments);
^

Error [ERR_REQUIRE_ESM]: require() of ES Module /var/www/vhosts/deunacolombia.com/desarrollo.deunacolombia.com/deunacolombia-node/index.js from /usr/share/passenger/helper-scripts/node-loader.js not supported.
Instead change the require of index.js in /usr/share/passenger/helper-scripts/node-loader.js to a dynamic import() which is available in all CommonJS modules.
at Module.require (/usr/share/passenger/helper-scripts/node-loader.js:80:25)
at loadApplication (/usr/share/passenger/helper-scripts/node-loader.js:243:2)
at setupEnvironment (/usr/share/passenger/helper-scripts/node-loader.js:214:2)
at Object.<anonymous> (/usr/share/passenger/helper-scripts/node-loader.js:133:1) {
code: 'ERR_REQUIRE_ESM'
}

I tried a workaround from the same forum by creating an index.cjs file containing

import('./index.js').then(() => console.log('@@@@@@@ WORKED')).catch(e => console.log('@@@@@ @@ FAILED', e.message, e.stack));

making sure that the executable was that file.

View attachment 24511

Now the page has a 504 error

View attachment 24512
I use .ejs as templates and the page views are located here...
View attachment 24513

Does anyone have a solution please

Thanks
The "document root" file is in..

In this folder are located all the views of the web page.
1697123282341.png
 
Solution:

I found the solution here:
Followed these steps and solved it.

  1. Create loader.cjs in your root file.
  2. Import your main file dynamically into the loader.cjs:


async function loadApp() {
await import('./index.js');
}
loadApp();

3. Go to your Node App in cPanel

4. In the "Application startup file", replace your main file with loader.cjs

5. Save and restart your app.

(if it doesn't work, destroy the project, then delete all files in the file manager and follow these steps again)
 
Back
Top