Noting that I do not use webpack, I received the exact same error after upgrading Electron from v8.1.0 to v11.2.0
My error appeared to originate from the use of the "__dirname" variable when used in the Electron "new BrowserWindow" -> "icon" setting.
As you are using modules, I suspect it may have something to do with the "new BrowserWindow -> webPreferences -> nodeIntegration" and "contextIsolation" scope settings, thus your need to set __dirname: true
in your "webpack.config.js" file (Ref: https://webpack.js.org/configuration/node/)
PS: I'm not full bottle on the updated Electron "nodeIntegration" and "contextIsolation" settings as I only updated my app this morning for the first time in a long time and learnt of the changed / pending default setting(s) of Electron v12.
More information can be found below:
Funnily enough, my original "icon" value was icon: __dirname + '',
. I had set this early on during development and subsequently forgot to point it to a proper *.ico file later on.
I just created an "icon.ico" file and set the "icon" value accordingly.
icon: __dirname + '/../../../icons/icon.ico'
This seemed to work.
As an alternative, I also tried the following (with the "icon" line commented out).
win.setIcon(__dirname + '/../../../icons/icon.ico');
This worked as well.
Note to self: Refactor to the path -> join function.
Important: That all said, I currently have set nodeIntegration: true
. Better sort this out before upgrading to Electron v12.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…