I have an electronic application where I need to not only launch an interface for a user, but also launch an express server that will serve files for people connected via a network.
Everything works for me if I run both an electronic and an express server, but I'm sure that I will need a server running in a different thread to avoid a problematic interface and even server problems.
In this regard, I tried to start my express server using child_process.fork, and it worked when I use npm start , but when I use electron-builder to create .exe, the installed program does not start the express server.
I tried to start my server immediately using:
require('child_process').fork('app/server/mainServer.js')
I tried several changes, the __dirname file __dirname , process.resourcesPath and even hard-coding the generated file path; changing fork parameters for passing cwd: __dirname , detached: true and stdio: 'ignore' ; and even tried using spawn with process.execPath , which will also work with npm start , but will not be packaged (it will open new instances of my application, it seems obvious after you)
Note. If I donβt fork and do not require the script server immediately, using require('server/mainServer.js') , it works with the packaged application, so the problem is no longer an expression.
Note 2: I have asar: false to solve other problems, so there is no problem here.
I set up a small git project to show my problem:
https://github.com/victorivens05/electron-fork-error
Any help would be greatly appreciated.
Victor Ivens
source share