Closed debussy2k closed 8 years ago
Hi @debussy2k ,
In order to help you I would ask that you create a small repository that replicates the problem.
Perhaps something with a gulp script that fires a sample electron app packaged with asar?
Thanks
Yaniv
I think it is fixed in Electron v0.35.3. (https://github.com/atom/electron/releases) Please see "Fix child_process.execFile not working for files in asar archive."
And you can also find details of Electron issue#3512 at https://github.com/atom/electron/issues/3512 Thanks!
Excellent, can you confirm so we can close this issue?
@debussy2k How did you end up implementing this? I've tried keeping node_modules\regedit
unpacked, but still get the same error unless I don't pack the app as asar.
Ok, got it worked out. in case anyone else stumbles across this here's what I went with. Basically, you need to explicitly point to the unpacked module dir. Somehow I thought asar may do some magic on that one, but I was mistaken.
let appPath = app.getAppPath()
let isAsar = !!appPath.match(/\.asar$/)
let basePath = path.resolve(appPath, '..', '..')
let unpackedPath = isAsar
? path.resolve(basePath, 'resources', 'app.asar.unpacked')
: path.resolve(basePath, 'resources', 'app')
let regeditPath = path.resolve(unpackedPath, 'node_modules', 'regedit')
let regedit = isAsar ? require(regeditPath) : require('regedit')
Thanks for sharing the solution.
@doesdev has just saved my life. Thanks!
Update for those that are still running into this problem and don't want to use the above hack, use this.
https://github.com/epsitec-sa/hazardous Simply use is like this
require ('hazardous');
const regedit = require ('regedit');
When I use node-regedit functions in Atom Electron that packaged with asar, node-regedit functions failed. Beacuse wsf files packaged in asar file don't exist in normal file system, calling wscript with wsf file fails. If wfs files were copied in temporary folder in this case and called with that, it would be a solution. I will appreciate if you support asar situation in Electron. Thanks!