如何将电子应用程序编译为 .exe [英] How To Compile An Electron Application To A .exe

查看:55
本文介绍了如何将电子应用程序编译为 .exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在学习如何在 Electron 中创建应用程序,我需要帮助将一个简单的项目编译为Windows 可执行文件.该程序是此 Github 存储库的克隆:https://github.com/electron/electron-quick-开始.在 repo 自述文件中,它显示了如何运行该程序:

I've been learning how to create applications in Electron and I need help compiling a simple project to a Windows executable. The program is a clone from this Github repo: https://github.com/electron/electron-quick-start. On the repo readme it shows how to run the program:

# Clone this repository
git clone https://github.com/electron/electron-quick-start
# Go into the repository
cd electron-quick-start
# Install dependencies
npm install
# Run the app
npm start

这很好用,但我不知道如何简单地编译它.我在谷歌上找遍了,你会认为像部署应用程序这样简单的事情会是众所周知的信息.

This works fine, but I can't figure out how to simply compile it. I've looked all over google, you would think that something as simple as deploying an application would be well known information.

推荐答案

你需要使用电子打包器.

安装它使用:

# for use in npm scripts
npm install electron-packager --save-dev

# for use from cli
npm install electron-packager -g

并使用以下方法打包或部署:

And package or deploy using:

electron-packager <sourcedir> <appname> --platform=win32 --arch=x86_64

如果您想在 Electron 安装中保留它,请参阅 应用程序分发.

If you would like to keep it with the Electron Installation, see Application Distribution.

更新:

以上命令可能会报错

不支持的 arch=x86_64(字符串);必须是匹配的字符串:ia32、x64、armv7l、arm64、mips64el

Unsupported arch=x86_64 (string); must be a string matching: ia32, x64, armv7l, arm64, mips64el

建议使用 ia32、x64、armv7l、arm64、mips64el 中的一个选项

Suggested to use one of the options from ia32, x64, armv7l, arm64, mips64el

electron-packager <sourcedir> <appname> --platform=win32 --arch=x64

这篇关于如何将电子应用程序编译为 .exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆