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?
there I found a new solution, using electron-packager on Windows do not add the files into the resources folder at the end of the process.
So I added this command into the
package.json
And now the files are insied the resource fodlder just add
Managed to solve it by using extraResources. Should be declared under build in your
package.json
file.For example:
Add the following code to your
package.json
file:"build": { "extraResources": ["./extraResources/**"] }
__dirname + '/../extraResources/'
from your main app.Add the following code to package.json:
Then, you can access the files using
I use the following folders structure which allows me to run the app any way.
from project folder:
node_modules\.bin\electron.cmd src\main\index.js
from unpacked source
dist\win-unpacked\app.exe check-for-update
from installed folder
C:\Users\user\AppData\Local\Programs\app\app.exe