![](/img/trans.png)
[英]Why getStaticProps giving error of "Failed to load SWC binary for win32/x64"?
[英]Electron app won't open after compiling for Win32 x64
我有一个问题。 我正在用电子创建一个应用程序,当我将它编译为它构建的 .exe 文件时,但还没有在我的笔记本电脑上启动/创建一个窗口。 我尝试关闭我的 Windows Defender,但这没有帮助。 每当我尝试使用我的 npm 脚本npm start
或electron .
运行它时electron .
有用。 有什么我做错了吗?
我运行将执行的npm run build
脚本mkdir build && electron-packager build ISS-Live-Locator --platform=win32 --arch=x64
我从电子文档中复制了这个main.js
文件。 并相应地更新了我的应用程序结构。
// Modules to control application life and create native browser window
const {app, BrowserWindow} = require('electron')
const path = require('path')
function createWindow () {
// Create the browser window.
const mainWindow = new BrowserWindow({
width: 800,
height: 600,
webPreferences: {
preload: path.join(__dirname, 'preload.js')
}
})
// and load the index.html of the app.
mainWindow.loadFile('index.html')
// Open the DevTools.
// mainWindow.webContents.openDevTools()
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.whenReady().then(() => {
createWindow()
app.on('activate', function () {
// On macOS it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
// Quit when all windows are closed, except on macOS. There, it's common
// for applications and their menu bar to stay active until the user quits
// explicitly with Cmd + Q.
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit()
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
谢谢! 希望这是有道理的。
您的构建命令似乎有误。
有关命令的签名,请参阅electron-packager
的文档:
electron-packager <sourcedir> <appname> --platform=<platform> --arch=<arch> [optional flags...]
您在mkdir build && electron-packager build ISS-Live-Locator --platform=win32 --arch=x64
基本上是尝试使用新创建的build
文件夹作为源目录。 因此,您的应用程序应该是空的并且无法运行。
此外,您应该Unable to determine Electron version. Please specify an Electron version
Unable to determine Electron version. Please specify an Electron version
错误,因为您没有指定电子版本。
试试这个构建命令:
electron-packager . ISS-Live-Locator --platform=win32 --arch=x64 --electronVersion=10.1.1
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.