Electron 如何打包生成exe安裝包,注意是安裝包。

三月發表於2022-01-21

我們用electron打包生成跨平臺軟體,官方推薦的打包方式先說一下有兩種.
第一種是:electron-packager
第二種是:electron-builder
這兩種有什麼不同呢?
1.electron-packager 打包會生成
image.png
這樣一個資料夾,裡面有exe的軟體開啟直接用
(這不是安裝包 是個資料夾)

2.electron-builder 打包會生成
image.png
這樣的多型別的安裝程式
*注意本文講的就是第一種electron-packager 打包 不能生成安裝包的解決方案
這裡就要提一下 nsis 這個東西了!

NSIS中文版下載地址:https://pan.baidu.com/s/1mitSQU0
也可以自行百度下載
關閉防毒軟體 一直下一步 安裝完成

然後傻瓜式安裝如下;
1
3b7411771fac7851c9c29f6359301c05f1db1edce88cde83b1a29a2ca95dfcb5QzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI4NjQ1MTg4XzNFMzE2RjQzLTI1RjMtNGQzZS1CQkEyLUFFNEMwOTVGRDFEOC5wbmc=.png
258aeb9e51c72d9777d8619ae8b0008e56380d4e227a122271f9228d33b369c1bQzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI4Njc3MDYyX0FGNTVCQTc1LTcxOTEtNDU1NS1BQzk2LTE4NDk2RDRDNDg4RC5wbmc=.png
37286822f48a97b3f0d8c71d97966899a4b2c6f6300202760ef31528d6383ea2eQzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI4NzEyNjkzXzNGQjAwMENELTA0MEQtNDBkYy1CRjdFLTRBMzI0RkRERTY1NS5wbmc=.png
4719b0e4088e46ae97ff0a9e1bae3967f1bf9576d5022291e8d755f2ec21eb39aQzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI4ODM4NzQxXzcxRTU1NEFBLTNEMDMtNGY0Zi05ODAzLUFEMUJBOEJFMEY0QS5wbmc=.png
可以更新自己軟體的資訊,然後下一步
5
52ea5821c8aa52f72b5f192297790edc6ba3f601821e77abeb589b79196dddbfQzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI4ODg1MzU3XzE4NDEzN0Y3LTgwNTItNDdiOC04MjE0LTZDQUY5Q0EyRDNCQi5wbmc=.png
669304c5f2493e23a0e6bc08df5a56d5dbcfc5f74b92d277a7dda1e2292ddcb73QzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5MDA4MzI2XzNFMTc1NjQyLTQ1MjYtNGZmMi05QjhCLTA2NkUwQjIyN0Y0NC5wbmc=.png
74322fa98cec50e8f773991f13b0be2c8c21bfe233d3c6ef844d5ab1ce2d6b1e6QzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5MDU5NjY5XzVDMzFDNUYzLThFRDMtNDdkZC04NTM1LTZDMTE3MzM5NkY2NC5wbmc=.png
注意刪掉授權檔案 刪除 刪除 刪除
810328cf6f213cc45fbffa775f6589c17f8cba8b949e18946fc4b10ba6678ad8aQzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5MTAwODkzXzU1MzQzMTI3LTQ3MjMtNDY4ZC05NUQ0LTZBN0ZDQzU1Q0VCNy5wbmc=.png
刪除 刪除 刪除
9 最關鍵的一步
746571cf7d31adc6536e9f922345a596fc348e5724545ed6f37f879d1f13071dQzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5MTE4NDEzX0YxQTVGQzVELUMzOTItNDMxNS1CRjhGLTY2NDUxQzlGQkM1Ny5wbmc=.pngcf03345513f270792d58cbdd40e817ac038b4ddfd95dd2a0854d45e38822f2f9QzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5MTgzNDIxXzA5MjUzN0JBLTMyNjMtNDg3Ny1CQkYyLTEwMDIzNjdGMTFBNy5wbmc=.pngb8138dd016916e66307033e240eff8b92ad2e761d2a2775fc5626169a382ca18QzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5MjAyMzgxX0Y3MTVBMkI5LTA0M0MtNDRkOC1CNEI0LTQwNThCRDRFM0NEOS5wbmc=.png8adf01340f2db8f8549397556e6cf7bb7287a48d436f4eaab68ea686e3c52e98QzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5MjU5NDI5X0M0Qzg3ODFELURCQUMtNGNmNC04MjIxLTE1QzQzQTQwRkQzRS5wbmc=.png22f64ac2891aef7d9f1ea85744f452698c0b7567fe88ad87f241fd1f0c5ef4eeQzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5Mjc4NTAxXzdFREQ1MEYyLTc4QkQtNDIwOC1BNEQ2LUUyRDE1Njg1REZFOS5wbmc=.png
選擇electron-packager打包後生成的資料夾中的 exe 和全部資料夾 一定要點選 點選 點選
10c7b8469890c2aaaac3bb311b877d7386d84e99956dcd8e365f1e3e2599a4eb79QzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5Mjk5MzQxXzY5OTI4NUJBLTgwQ0YtNGE3Zi04MjZCLTM5MEI3NUZDOTYwNS5wbmc=.pngf5bf9b0e7d7504a62750f4d03a51b52801eb5a71b218a7b40805b615316f5cbbQzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5MzE2OTQ5X0UyOTU1ODczLTcxNjgtNGIyMi1BRjNFLTBGRjRBMTJENUQxRS5wbmc=.png68213ab4d87a3dbe237c167a126e27d6717f93baff870f459d7eb7f4303be142QzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5MzM2NjUzXzVBODNCMEQ1LUE0M0UtNGVlMC05OTM5LTFFMUYwMTdGQTNDQi5wbmc=.png
一直下一步
11.80f84fbe31960d4a0fee8a5d4f59bab7ca4537b7c94cac0ebedfc7a6d28dff4aQzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5MzU0MzAxXzE0NjE5NjE5LUQxMkYtNDU4Ni1BMzExLUY2NzhFREM0QUY2Ni5wbmc=.png
全部勾選
12.03d5fe080ee6104a5040e2197b6f5fc377901e304d7bdafe5aa342cb6d17279dQzpcVXNlcnNcaHR3aW5zXEFwcERhdGFcUm9hbWluZ1xEaW5nVGFsa1wzNjM4NTg0MzlfdjJcSW1hZ2VGaWxlc1wxNjQyNzI5OTY2NjIzXzI2NDMyQTZGLUFDOUUtNDMzNy05ODQwLTE2NTk1OTdBOTg4RS5wbmc=.png
選擇安裝包出生的位置!
然後你就得到了安裝程式!

相關文章