Electron Builder: Not allowed to load local resource: app.asar/build/index.html

19,151

Solution 1

Solved by adding "files" in package.json

"files": [
  "*.js",
  "build",
  "node_modules"
],

Solution 2

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.

dist/project-name/index.html

Solution 3

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);

Solution 4

I tried to fix this my whole day & finally found the solution,

"build": {
"appId": "myledgerapp",
"extends": null,
"files": [
  "./build/**/*",
  "./public/electron.js"
]}

We need to add files in build section where electron.js is my entry point.

Share:
19,151

Related videos on Youtube

Emre Tekince
Author by

Emre Tekince

Updated on June 04, 2022

Comments

  • Emre Tekince
    Emre Tekince almost 2 years

    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);
    
  • Vahid Kharazi
    Vahid Kharazi over 5 years
    This is not worked for me. what the files actually do?
  • awebdev
    awebdev about 5 years
    How do you know what to add to "files"?
  • Pranav s
    Pranav s over 3 years
    Where should I add the Files? I have added it to my package.json.But no change, the error persists
  • cyberchis
    cyberchis over 2 years
    I used this as well as moving my html file into the static folder. So I just added "static" to the list inside of "files".
  • Vass
    Vass almost 2 years
    @Akashxoloti, but what does 'files' do if included?