Okay, so it seems that sometimes when I PIE the Main Script does not connect.
When it successfully does, after about a minute SocketIO just disconnects (CLOSE_REASON_NORMAL) and then I have to restart the editor to be able to make the nodejs script run again.
I stumbled upon the answer to my own question. So, the script I am running requires me to install node modules in the Scripts folder. When I try calling the ipc-event-emitter module from the script, it cannot find it in the Scripts folder. I tried installing the node-ipc-event-emitter directly into the Scripts folder but I think there’s some necessary modules that are not included in that installation (I would be forever grateful if you could point me towards the right one).
So, I copy/pasted only the node_modules folder from Plugins\nodejs-ue4\Content\Scripts and skipped any repeated files to make sure I had all necessary modules present in the Scripts folder.
The packaged project should force the plugin to include a local embedded node and npm, but may have to just add a folder to package copying step in settings for everything to work as expected.