• Hi, Pleskians! We are running a UX testing of our upcoming product intended for server management and monitoring.
    We would like to invite you to have a call with us and have some fun checking our prototype. The agenda is pretty simple - we bring new design and some scenarios that you need to walk through and succeed. We will be watching and taking insights for further development of the design.
    If you would like to participate, please use this link to book a meeting. We will sent the link to the clickable prototype at the meeting.
  • (Plesk for Windows):
    MySQL Connector/ODBC 3.51, 5.1, and 5.3 are no longer shipped with Plesk because they have reached end of life. MariaDB Connector/ODBC 64-bit 3.2.4 is now used instead.
  • 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.

Issue Node.js install not working

Fabian H

Basic Pleskian
Using the node.js extension, the node server (port bound with express) cannot start as it seems.
The /var/log/httpd/error_log is giving this error:
Code:
App 1168143 output: /usr/share/passenger/helper-scripts/node-loader.js:80
App 1168143 output:     return originalRequire.apply(this, arguments);
App 1168143 output:                         ^
App 1168143 output: 
App 1168143 output: Error [ERR_REQUIRE_ESM]: require() of ES Module /var/www/vhosts/sitemap-finder.com/httpdocs/server.js from /usr/share/passenger/helper-scripts/node-loader.js not supported.
App 1168143 output: Instead change the require of server.js in /usr/share/passenger/helper-scripts/node-loader.js to a dynamic import() which is available in all CommonJS modules.
App 1168143 output:     at Module.require (/usr/share/passenger/helper-scripts/node-loader.js:80:25)
App 1168143 output:     at loadApplication (/usr/share/passenger/helper-scripts/node-loader.js:243:2)
App 1168143 output:     at setupEnvironment (/usr/share/passenger/helper-scripts/node-loader.js:214:2)
App 1168143 output:     at Object.<anonymous> (/usr/share/passenger/helper-scripts/node-loader.js:133:1) {
App 1168143 output:   code: 'ERR_REQUIRE_ESM'
App 1168143 output: }
App 1168143 output: 
App 1168143 output: Node.js v17.3.0
[ E 2021-12-23 11:44:24.1727 1166900/T1n age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/vhosts/sitemap-finder.com/httpdocs: The application process exited prematurely.
  Error ID: aff98d91
  Error details saved to: /tmp/passenger-error-qXrxkJ.html

[ E 2021-12-23 11:44:24.1772 1166900/T9 age/Cor/Con/CheckoutSession.cpp:276 ]: [Client 1-3] Cannot checkout session because a spawning error occurred. The identifier of the error is aff98d91. Please see earlier logs for details about the error.

The file /tmp/passenger-error-ioV4eJ.html does not exist anyway.

I try running with cli (/opt/plesk/node/17/bin/node server.js), there are no errors on startup, so modules seems to be installed correctly.
 
Ouh, I'm not sure how, but I did.
Right now, the app is running with Node v17.8.0 and the require() commands.
 
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)
 
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)
Thanks for sharing the link and the detail related to using it. This is helpful.
 
Back
Top