I packaged my electron-app but a js error occurred in the main process

28 views Asked by At

error description

#electron entry file

import { app, BrowserWindow } from "electron";
const url = require("url");
const path = require("path");
function createMainWindow() {
    const mainWindow = new BrowserWindow({
        title: "test-window",
        width: 1080,
        height: 1920
    });
    mainWindow.webContents.openDevTools();
    const startUrl = url.format({ pathname: path.join(__dirname, './my-app/build/index.html'), protocol: 'file' });
    mainWindow.loadURL(startUrl);
}

app.whenReady().then(createMainWindow);

app.on('window-all-closed', () => {
    if (process.platform !== 'darwin') app.quit()
});

I bundle my app with CRA and then load it to electron entry file. I use electron-builder to package it and there are no warnings in terminal.Seems like I have successfully packaged my app. But when I try to run it,it doesn't work

EDIT 1:

debug tool details

I managed to package it but it still doesn't work. It seems my resources files wasn't precompiled porperly in electron-builder (css file have nothing but an error report says file not precompiled). But it's strange that when I use electronmon in dev mode to test it,it can function correctly.So what goes wrong?

0

There are 0 answers