[SOLVED] Pass a packed JS module from within an asar package to a spawned node child process as argument


When trying to spawn a child_process that runs node path/to/a/packed/file I am getting Cannot find module error because the path is within app.asar

Error: Cannot find module 'C:\Program Files (x86)\my-app\resources\app.asar\bootstrap\daemon'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

I understand this is because the unpatched node is trying to locate the bootstrap/daemon as a physical file. And I have the same issue on Windows as well as OS X.

Can someone who is more familiar with the asar documentation/code advise a workaround to this?

I had raised this question as an issue on the GitHub repo as well.

Thank you very much!

Not able to spawn npm modules from Electron Package in OS X [solved]

The suggestion from https://github.com/atom/electron/issues/1613#issuecomment-100146829 to add an environment variable of {ATOM_SHELL_INTERNAL_RUN_AS_NODE : 0} helped to successfully resolve the issue with using fork in place of spawn

More details can be seen on the GitHub issue