Socketio: ERROR (spawn error) in production

Hey Everyone,

While trying to enable production mode I ran this command:

sudo supervisorctl restart all

But I got this:

frappe-bench-web:frappe-bench-node-socketio: ERROR (spawn error)

I checked the frappe-bench/logs/node-socketio.error.log and I found this error:

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/frappe/frappe-bench/apps/frappe/node_modules/@redis/client/dist/index.js:18:18)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
/home/frappe/frappe-bench/apps/frappe/node_modules/@redis/client/dist/lib/client/index.js:35
            modules: extensions?.modules,
                                ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/home/frappe/frappe-bench/apps/frappe/node_modules/@redis/client/dist/index.js:18:18)
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

I found multiple threads talking about it, but nothing seems to work. Any tips?

This could be your node version issue. Please check the version of the NodeJS and then Frappe along with other apps. Hope upgrading to 18 will help you if you are using Version-15.

My Node.js version is 18, but I’ve tried versions 20, 21, and 22 with no luck.
I think the issue might be because I’m using the root user on Ubuntu 22, which causes a clash with the default Node.js version 12.
I’m going to reinstall it under a new user and see what happens.
Thanks for the suggestion!

Hi mohammad,

did you manage to fix your issue, please share to me how you fix it

Hey man,

Sorry for the late response.
Yes, I managed to fix the issue.
As I stated the issue was a clash between the default ubuntu node version & the installed node since I was working on the root user.

What I did is I created a new user and installed the frappe bench on it then I used this code block:

Bench Restart Socket.io Spawn Error - ERPNext - Frappe Forum

Hi mohammad-ihraiz,

Sorry I’am not quite new to ERPNext, the link that you gave me is ok but I dont know how to use that script, can you please tell me how to execute that code

Thanks in advance

This is a bash script that can be executed via the terminal. You can copy and paste it into your Ubuntu terminal while inside the frappe-bench directory.

Mohammad-ihraiz,

Thanks for your help… It’s work now.

Good for you man :heart: