__dirname is a NodeJS variable, in recent electron versions, node integration is disabled by default. When opening your BrowserWindow, you should add the following to the options:
module.exports = { pluginOptions: { electronBuilder: { nodeIntegration: true } } }
this seems to solve it for most people (for me sadly enough i now get the next error: fs.existsSync is not a function)