'child process is not working in electron app
I'm creating a child process using "fork" in the "electron" app. I'm creating child process as below:
const child_process_file = path.join(__dirname, 'getSubFolders.js')
const sub = fork(child_process_file, [JSON.stringify(subFolderObj), JSON.stringify(arg)])
when I run this program in debug mode, the child process is working fine, but when I generate an exe file and run the exe file, child process is not working as it should be. It is targetting main.ts(main file) instead of a file('getSubFolders.js' here) passed in params while creating child process.
path generated for child_process_file is => C:\Users\Saurabh\AppData\Local\Programs\INSTALLED_EXE_PATH\resources\app.asar\two-way-sync\getSubFolders.js
can anyone suggest what am i doing wrong in this?
Solution 1:[1]
I got a solution and it is working for me.
const env = { ...process.env, PATH: `${process.env.PATH}:/usr/local/bin` };
const child_process_file = path.join(__dirname, 'getSubFolders.js')
const sub = fork(child_process_file, [JSON.stringify(subFolderObj), JSON.stringify(arg)], {
env,
stdio: ['ipc', out, err]
})
Make sure that you are not using any electron functionality in child process
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Saurabh Beladiya |
