I have an issue with Electron unable to load BrowserWindow preload script. With the next error line:
Unable to load preload script: C:\Users\user\AppData\Local\Programs\myApp\resources\app.asar\electron\preload.js
Here are the versions I use: "electron": "^11.0.1", "electron-builder": "^22.3.6". Also here is the script I launch the new window:
const win = new BrowserWindow({
width: 1400,
height: 900,
frame: false,
title: title.name,
webPreferences: {
frame: false,
webviewTag: true,
nodeIntegration: true,
enableRemoteModule: true,
nodeIntegrationInWorker: true,
preload: path.join(`${__dirname}/electron`, 'preload.js'),
},
});
The weird part about this is that I have another Electron app with an older Electron version and I have no issues whatsoever, versions: "electron": "^8.2.3" & "electron-builder": "^22.5.1".
const win = new BrowserWindow({
width: 1400,
height: 900,
frame: false,
title: title.name,
webPreferences: {
preload: path.join(`${__dirname}/electron`, 'preload.js'),
nodeIntegration: true,
nodeIntegrationInWorker: true,
webviewTag: true,
},
});
The only differences I have is nodeIntegrationInWorker and enableRemoteModule. Are any of these properties not allowed to work together? Or is this the Electron version deprecating some of them? How can I fix the error