Angular + Electron app goes blank after Ctrl+R

Discussão em 'Angular' iniciado por Cooper S, Abril 24, 2025.

  1. Cooper S

    Cooper S Guest

    On the latest version of both Angular and Electron. First load works fine, but then any refresh will blank the screen.

    Reload the page, and it blanks. Will log in console: (node:44678) electron: Failed to load URL: file:///Users/--/Documents/PersonalProjects/aviata-angular/dist/renderer/ with error: ERR_FILE_NOT_FOUND - missing the trailing index.html that is loaded in my main.js.

    main.js

    const { app, BrowserWindow } = require('electron');
    const path = require('path');

    app.on('ready', () => {
    const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
    nodeIntegration: true,
    contextIsolation: false,
    },
    });

    mainWindow.loadFile(__dirname + '/dist/renderer/index.html');
    });


    package.json start "start": "ng build --base-href ./ && electron ."

    I've attempted the useHash/withHashLocation fix here, but it didn't work. Suspect this is with the latest version of Angular only.

    Continue reading...

Compartilhe esta Página