TypeError: Cannot read properties of undefined (reading 'on') with SvelteKit and Plesk

36 Views Asked by At

I'm encountering an issue while deploying a SvelteKit demo application on a Plesk server. After following the steps to get the SvelteKit demo ready for production, I performed a build which resulted in two directories: client/ and server/ and some files. To start the application, I created an entry.cjs file with the following line:

(() => import('./index.js'))();

I then set this entry.cjs file as the startup file in the Node.js application settings on Plesk.

However, when I try to access the application via the browser, I receive the following error:

App 32610 output: server.server.on(
App 32610 output:               ^
App 32610 output: 
App 32610 output: TypeError: Cannot read properties of undefined (reading 'on')
App 32610 output:     at file:///var/www/vhosts/programr.events/httpdocs/build/index.js:285:15

It seems this error is related to an attempt to access an on method on an undefined server object. Here are the steps I've taken for deployment:

  • Build the SvelteKit application using npm run build, which produces client/ and server/ directories.
  • Creation of the entry.cjs file to start the application.
  • Configuring entry.cjs as the startup file on Plesk.

I'm a bit lost on how to resolve this issue. Has anyone encountered this error before, or does anyone have an idea on how to correctly configure a SvelteKit application for deployment on a Plesk server?

Thank you in advance for your help.

0

There are 0 best solutions below