I have an issue when using electron builder I got blank page and error in console:
Not allowed to load local resource: file:///C:/Users/emretekince/Desktop/DCSLogBook/client/dist/win-unpacked/resources/app.asar/build/index.html
main.js
const startUrl = process.env.ELECTRON_START_URL || url.format({
pathname: path.join(__dirname, '/build/index.html'),
protocol: 'file:',
slashes: true
});
mainWindow.loadURL(startUrl);
Solved by adding "files" in package.json
I also got the same issue i placed the below line before loading the file.
Example Code
I tried to fix this my whole day & finally found the solution,
We need to add files in build section where electron.js is my entry point.
I think your index.html file is not present in your given location.
__dirname, '/build/index.html'
I missed this silly point and wasted a lot of time. Angular-cli creates default location for index.html inside a folder in dist.
I had the same issue and managed to sort it out using:
path.resolve('index.html')
like this:
const startUrl = path.resolve('index.html'); mainWindow.loadURL(startUrl);