You probably need to do a patch like this instead of using __dirname
, because __dirname
will resolve to the ASAR when in production, as you have found:
const { app } = require('electron');
const rootPath = app.isPackaged ? app.getAppPath() : __dirname;
const worker = new Worker(path.join(rootPath, 'worker.js'));
https://www.electronjs.org/docs/latest/api/app#appispackaged-readonly
Note that based on your exact setup you may need to navigate up or down a folder in your production app, in which case you can use something like:
const rootPath = app.isPackaged ? app.getAppPath() : path.join(__dirname, '..');