When a button is clicked in my app, a child process is spawned using the fork() function. This works as intended, even when bundled into an exe in my dist folder (via electron-builder). However, when I move the folder win-unpacked to another folder for testing, the child process is not spawned.
The dist folder structure is as shown:
dist
|-.icon-ico
|- win-unpacked
|- builder-debug.yaml
|- builder-effective-config.yaml
The win-unpacked is where all the main files are (such as app.asar, app.exe and such).
When it is in my main development folder such as this:
app
|-build
|-node_modules
|-dist
|-public
|-src
The child process is spawned, however, in the testing folder which just contains dist, the child process is not spawned.
To spawn the child process I have used:
child = fork(require("path").join(__dirname, "sts/states.js"));
In console, the __dirname is logged as C:\Users\me\Documents\mainApp\dist\win-unpacked\resources\app.asar\build.
the sts folder is located in build folder.
I do not actually know what the reason is to why this is not working when I take dist out of my app folder and place it into another folder for testing.
With some help from this answer, I managed to get some direction. I added:
"build": {
"extraResources": "node_modules",
"files": [
"!node_modules"
]
}
to my package.json and now it is spawning the child process. The downside is that the file is now larger (1.45GB).