I have an Electron app. I try to make the app open an .exe file. I created a directory in the root folder named lib
and placed the .exe file there. In development, I have no problem opening the file by using __dirname + '/lib/file.exe
, but when I package the app (using yarn dist
), it does not open the exe file and there is no lib
folder anymore on the dist
folder.
I tried writing to console the default location using console.log(__dirname)
and it outputs \dist\win-unpacked\resources\app.asa
(which is a file).
How can I add an external file that can be accessed when the app is packaged?
Managed to solve it by using extraResources. Should be declared under build in your
package.json
file.For example:
Create a new folder named extraResources adjacent to pacakge.json
Add the following code to your
package.json
file:Then, you can access the files inside this folder by using
__dirname + '/../extraResources/'
from your main app.