Cannot find module ../electron.asar/browser/init.js


#1

Once I build my electron app using electron-packager, my requirement is to run it on a clean mac with no node installed. The app spawns a child process to which I used ‘process.execPath’ as command which is the path to the node executable bundled into electron app. But I am facing the following issue. My code looks like this:

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

 let func = () => {
   fixPath();   
   const child = childProcess.spawn(process.execPath, ['/src/script.js', ...someFlag arguments],  {
     detached: true, 
     // stdio: 'ignore',
 });
 child.on('error', (err) => {
   console.log("\n\t\tERROR: spawn failed! (" + err + ")");
 });

 child.stderr.on('data', function(data) {
   console.log('stdout: ' +data);
 });

 child.on('exit', (code, signal) => {
   console.log(code);
   console.log(signal);
 });

 child.unref();
 }

**Console output **

    stdout: module.js:545
    throw err;
    ^

Error: Cannot find module '/Users/testpc/Desktop/appName.app/Contents/Frameworks/appName Helper.app/Contents/Resources/electron.asar/browser/init.js'
    at Function.Module._resolveFilename (module.js:543:15)
    at Function.Module._load (module.js:473:25)
    at Function.Module.runMain (module.js:683:10)
    at startup (bootstrap_node.js:196:16)
    at bootstrap_node.js:622:3

**command line arguments I am passing? **

      electron-packager . appName --overwrite --electron-vesrion=2.0.4 --no-asar --platform=darwin 
      --arch=x64 --icon gui/assets/icons/mac/logo.icns --out=package