In electron packaged app, I am trying to execute a server file from a node_modules dependency. From the main process, I'm trying something like:
var cp = require('child_process')
cp.execFile('node', path.join(__dirname, 'node_modules/my-module/server.js'))
I see the server is launched as expected when launching my app from my local command-line, but not when packaged as asar. What is the right way to achieve that?
Notes:
I have looked into https://electron.atom.io/docs/tutorial/application-packaging/#executing-binaries-inside-asar-archive:
There are Node APIs that can execute binaries like child_process.exec, child_process.spawn and child_process.execFile, but only execFile is supported to execute binaries inside asar archive.
Also, saw this SO answer:
Executing a script inside an ASAR archive which says I need to require
my script - however, I think it's wrong. This actually spawns this script within the same process (once required) and not when performing execFile
.