Launching a child process from packaged electron app to run as a node process:


I have a packaged electron app that I wish could run on a mac with no node installed on it. My app uses child process exec method to run a node command and I face a ‘node not found’ error. The code works well in a machine with node installed but on a new mac it gives the error. I tried setting the env variable RUN_ELECTRON_AS_NODE, but this didn’t work either. How can I run my app on a mac with no node installed?

I also tried using fork method which actually didn’t give me the ‘node not found’ error, but when I use fork the process exits immediately, I wish there is a way to catch that error when using fork.

My code looks like this:

'use strict'
const fixPath = require('fix-path');

let func = () => {
    const child = childProcess.exec('node scriptPath --someFlags', {
    detached: true, 
    stdio: 'ignore',
    env: {
child.on('error', (err) => {
  console.log("\n\t\tERROR: spawn failed! (" + err + ")");
  // todo
child.stderr.on('data', function(data) {
  console.log('stdout: ' +data);
child.on('exit', (code, signal) => {