• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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