gpt4 book ai didi

javascript - 如何将 Electron 应用程序编译为 .exe

转载 作者:行者123 更新时间:2023-12-02 22:10:31 26 4
gpt4 key购买 nike

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

# 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

这工作正常,但我不知道如何简单地编译它。我查遍了谷歌,你会认为像部署应用程序这样简单的事情就是众所周知的信息。

最佳答案

您需要使用Electron Packager .

安装使用:

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

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

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

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

如果您想将其与 Electron 安装一起保留,请参阅 Application Distribution .

更新:

以上命令可能会引发错误

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

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

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

关于javascript - 如何将 Electron 应用程序编译为 .exe,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40615837/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com