Open markgillnz opened 6 years ago
IIRC, it skips in the case where the caller is in ELECTRON_ASAR or electron.asar because child_process.spawn/exec
is already aware of asar.unpack
dir. Patching here breaks the node spawner.
And your error seems elsewhere.
Error: Cannot find module 'C:\Users\FlyingSquad\AppData\Local\EMRConnect\app-1.4.0\resources\app.asar\node_modules\sqlite3\lib\binding\electron-v1.4-win32-ia32\node_sqlite3.node'
node_sqlite3.node is a binary, not a node module. It doesn't make sense.
child_process
API must be used here. I don't understand.. or maybe it's just because require('node-pre-gyp').find
is already doing strange things with require()
.
Can you provide a sample please?
OK; I think that now I understand. I never played with native addons and require
supports binary files. https://nodejs.org/api/modules.html#modules_file_modules
But even in this case, it should work. I think that the problem is around the lines 310 and 313 of node-pre-gyp
. https://github.com/mapbox/node-pre-gyp/blob/master/lib/util/versioning.js#L310
According to the comments, it's using relative paths (and with hazardous it's a problem). I must investigate step by step by debugging this stuff.
@markgillnz Have you tried without unpacking sqlite3? It should work because nothing is spawned.
@Skywalker13 yes. Originally I did not have sqlite3 unpacked and got the error in my first post.
There is a comment as below that skips monkey patching when an electron method is in the callstack but no reasoning behind this decision.
/* Skip monkey patching when an electron method is in the callstack. */
Can you explain why you skip patching in this case as it means sqlite3 cannot be used within Electron with asar enabled and sqlite3 unpacked.
Error I am seeing:
{ Error: Cannot find module 'C:\Users\FlyingSquad\AppData\Local\EMRConnect\app-1.4.0\resources\app.asar\node_modules\sqlite3\lib\binding\electron-v1.4-win32-ia32\node_sqlite3.node' at Module._resolveFilename (module.js:455:15) at Function.Module._resolveFilename (C:\Users\FlyingSquad\AppData\Local\EMRConnect\app-1.4.0\resources\electron.asar\common\reset-search-paths.js:35:12) at Function.Module._load (module.js:403:25) at Module.require (module.js:483:17) at require (internal/module.js:20:19) at Object.<anonymous> (C:\Users\FlyingSquad\AppData\Local\EMRConnect\app-1.4.0\resources\app.asar\node_modules\sqlite3\lib\sqlite3.js:6:15) at Module._compile (module.js:556:32) at Object.Module._extensions..js (module.js:565:10) at Module.load (module.js:473:32) at tryModuleLoad (module.js:432:12) code: 'MODULE_NOT_FOUND' }