简体   繁体   English

为 Win32 x64 编译后,Electron 应用程序无法打开

[英]Electron app won't open after compiling for Win32 x64

I have an issue.我有一个问题。 I was creating an app with electron and when I compiled it to an .exe file it built, but haven't started/created a window on my laptop.我正在用电子创建一个应用程序,当我将它编译为它构建的 .exe 文件时,但还没有在我的笔记本电脑上启动/创建一个窗口。 I tried turning off my Windows Defender but that didn't help.我尝试关闭我的 Windows Defender,但这没有帮助。 Whenever I try to run it with my npm script npm start or electron .每当我尝试使用我的 npm 脚本npm startelectron .运行它时electron . it works.有用。 Is there anything that I'm doing wrong?有什么我做错了吗?

I run the npm run build script which will execute我运行将执行的npm run build脚本
mkdir build && electron-packager build ISS-Live-Locator --platform=win32 --arch=x64

I copied this main.js file from the electron documentation.我从电子文档中复制了这个main.js文件。 And updated my app structure accordingly.并相应地更新了我的应用程序结构。

// 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.

Thank you!谢谢! Hope this made sense.希望这是有道理的。

Your build command seems wrong.您的构建命令似乎有误。

See the docs of electron-packager for the command's signature:有关命令的签名,请参阅electron-packager 的文档

electron-packager <sourcedir> <appname> --platform=<platform> --arch=<arch> [optional flags...]

What you do in mkdir build && electron-packager build ISS-Live-Locator --platform=win32 --arch=x64 is basically trying to use the newly created build folder as source directory.您在mkdir build && electron-packager build ISS-Live-Locator --platform=win32 --arch=x64基本上是尝试使用新创建的build文件夹作为源目录。 Therefore, your app should be empty and can't run.因此,您的应用程序应该是空的并且无法运行。

Also, you should get Unable to determine Electron version. Please specify an Electron version此外,您应该Unable to determine Electron version. Please specify an Electron version Unable to determine Electron version. Please specify an Electron version error because you don't specify electron version. Unable to determine Electron version. Please specify an Electron version错误,因为您没有指定电子版本。

Try this build command instead:试试这个构建命令:

electron-packager . ISS-Live-Locator --platform=win32 --arch=x64 --electronVersion=10.1.1

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么 getStaticProps 给出“无法为 win32/x64 加载 SWC 二进制文件”的错误? - Why getStaticProps giving error of "Failed to load SWC binary for win32/x64"? Javascript window.open在Win7 x64上的32位IE8中返回null - Javascript window.open returns null in 32-bit IE8 on Win7 x64 如何修复 fsevents@2.1.3 不支持的平台:想要 {“os”:“darwin”,“arch”:“any”}(当前:{“os”:“win32”,“arch”:“x64”} ) - how to fix Unsupported platform for fsevents@2.1.3: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”}) window.open(“ \\\\\\\\ localhost \\\\”); 不适用于win7(x64)ie8 - window.open(“\\\\localhost\\”); not working on win7(x64) ie8 UWP JavaScript APP:带参数运行win32 EXE - UWP JavaScript APP: run win32 EXE with parameters 电子不会从 JSON 打开文件 - Electron won't open file from JSON 为什么window.navigator.platform 在64 位机器上返回WIN32? - Why does window.navigator.platform return WIN32 on a 64-bit machine? 在ie11中损坏的HTML5本地存储赢了8.1 x64? 错误:预期功能 - HTML5 local storage broken in ie11 win 8.1 x64 ? error: function expected PayPal灯箱无法在iPhone Safari /网络应用中打开; &#39;win.location&#39;未定义 - PayPal lightbox won't open in iPhone safari/web app; 'win.location' undefined X11 Xorg Electron App无法在全屏模式下打开 - X11 xorg Electron App cant open in fullscreen
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM