Try to open a HTML file that resides inside the packaged app app.asar file. The file is there but Windows complains that cannot find the file. The pieces of the puzzle are:
- inside the
win-unpacked\resources\app.asarfile there is\dist\doc\index.html - In the main ElectronJS process I confirm the file is here with
fs.existsSync("D:\Project\release\1.47.3\win-unpacked\resources\app.asar\dist\doc\index.html") - Then using
shell.openPath("<the above path>")to open it but failed with Windows opening a dialog saying cannot find the file and the routine returns "Failed to open path". Well, this makes sense because Windows has no idea of the asar filesystem.
So the central question is: How I open an html file in a browser from the app.asar file?
The temporary solution (I want to avoid for other problems related to the packaging process) is to copy the files under app.asar.unpacked/dist/doc/index.html
shell.openPathis not exactly an I/O API, it is a method ofshell, so it doesn't have to work with .asar. If so, it's a shame, of course. Are you sure the packaging without creation of .asar is not an option? If you don't use .asar, everything should work, and the volume of data is usually not so high relative to the other files of the package.shell.openExternal(fileURL);in my application, it used the file not in .asar (only a user-supplied files), and I would need some to try it out if it is in .asar. You could try it, but I doubt it can make a difference. (To calculatefileURLcorrectly in a portable way, we also needpath.normalizeand thenurl.pathToFileURL.)shell.openPathworks without .asar and does not work if the path is in .asar. Do you know that packing or not packing resources into .asar is a valid packaging option? I think the solution with not packaging it into .asar can also be used. Yourapp.asar.unpacked/dist/doc/index.htmlis also a viable solution.index.htmlfile (isn't it the application help file, or something like that?) into the packaged directory by the same script doing packaging, as a post-packaging step...