Ниже приведен мой пакет. json и main. js, получая следующую ошибку при попытке построить мой проект с использованием npm run dist
, как определено в разделе сценариев. Может запустить мое приложение в среде разработчика и также может чтобы упаковать мое приложение, используя электронный упаковщик , поэтому проблема заключается в коде электронного компоновщика здесь
пакет. json:
{
"name": "app",
"version": "1.0.0",
"description": "app",
"author": {
"name": "app"
},
"main": "main.js",
"scripts": {
"pack": "electron-builder --dir",
"dist": "electron-builder",
"build-win": "electron-packager . --platform=win32",
"publish": "electron builder --win -p always"
},
"private": true,
"dependencies": {},
"devDependencies": {
"electron": "^8.1.1",
"electron-packager": "^14.2.1",
"electron-builder": "^22.4.1"
},
"build": {
"appId": "app",
"win": {
"target": "NSIS"
},
"publish": [
{
"provider": "github",
"repo": "repo name",
"owner": "dev"
}
]
}
}
main. js
const { app, BrowserWindow, ipcMain, ipcRenderer } = require('electron');
// const ipcMain = require('electron').ipcMain
// const { ipcRenderer } = require('electron');
let mainWindow;
let splashScreen;
function createWindow() {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 1080,
height: 920,
skipTaskbar: true,
backgroundColor: '#ffffff',
show: false,
icon: __dirname + `/app/assets/images/favicon.png`
})
mainWindow.loadURL(`file://${__dirname}/app/index.html`);
mainWindow.setMenuBarVisibility(false);
// process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
//// uncomment below to open the DevTools.
// mainWindow.webContents.openDevTools();
// Event when the window is closed.
mainWindow.on('closed', function () {
mainWindow = null;
});
}
//splash screen //
function splashSceenInstance() {
splashScreen = new BrowserWindow({
// minWidth: 400,
// minHeight: 280,
width: 600,
height: 400,
center: true,
backgroundColor: '#e0eff8',
webPreferences: {
nodeIntegration: true,
webSecurity: false
},
frame: false,
skipTaskbar: true,
resizable: false,
alwaysOnTop: true,
});
splashScreen.loadURL(`file://${__dirname}/splashScreen.html`);
}
// Create window on electron intialization
app.on('ready', function () {
createWindow();
splashSceenInstance();
});
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On macOS specific close process
if (process.platform !== 'darwin') {
app.quit()
}
});
app.on('activate', function () {
// macOS specific close process
if (mainWindow === null) {
createWindow();
}
});
ipcMain.on('showMainWindow', () => {
setTimeout(() => {
splashScreen.destroy();
mainWindow.maximize();
}, 1000);
});
Описание ошибки: Epipe