I have a Electron project which executes some python script using NodeJS\'s child_process module. My python script is in the root folder of my project.
Here\'s how I cal
I've solved my problem. I'll explain for possible future readers with the same problem.
Using electron builder, there are some options possible for not to package the application source code into an electron file. These options are:
asar
Whether to package the application’s source code into an archive, using Electron’s archive format. Defaults to true. Node modules, that must be unpacked, will be detected automatically, you don’t need to explicitly set asarUnpack - please file issue if this doesn’t work.
Or you can pass object of asar options.
asarUnpack
A glob patterns relative to the app directory, which specifies which files to unpack when creating the asar archive.
DOCS
Setting asar
to false
solves the issue, but it is not recommended by electron-builder
.
So including all the files I need to unpack in a folder, and using
"asarUnpack" : "my-folder/*"
is the right way. Now all the files unpacked are available in /resources/app.asar.unpacked/my-folder
Another thing to take into account is that using the path './ResolvePosition.py'
is going to look at the root folder of my electron project, not the path where my NodeJS file is located, I need to use :
let python = spawn('python', [path.join(__dirname, '../app.asar.unpacked/my-folder', 'ResolvePosition.py'), obsFilePath, navFilePath])