vue+electron项目打包问题

打包报错关键信息:

Error: C:\Users\<我的用户名(英文)>\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.3.2\Bin\makensis.exe exited with code 1

......

Error output:
Can't open output file
Error - aborting creation process

    at ChildProcess.<anonymous> (D:\work\qiqi\qiqi\qiqi\node_modules\builder-util\src\util.ts:244:14)
    at Object.onceWrapper (events.js:520:26)
    at ChildProcess.emit (events.js:400:28)
    at maybeClose (internal/child_process.js:1055:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)

在网上查看了一些electron打包出错的解决博客,很多是因为项目路径或者electron-builder文件夹路径有中文,所以报错,附上解决博客:文件名有中文、打包后白屏两个问题的解决方案electron-builder路径有中文解决方法

但是在我自己的项目 这两个问题都没有,但是打包时好时坏,很不稳定。

问题分析:

自己的打包命令运行的是 npm run build,在package.json文件里面build被定义的是:

"build": "node .electron-vue/build.js && electron-builder",

自己的项目使用了node的环境打包。和网上一些其他electron项目的打包命令有区别。

建议使用  npm run dist,在package.json文件里面 dist 定义如下:

"dist":"electron-builder"

直接使用 npm run dist 进行打包,打包效果完全没有差别,甚至更快!

最后附上自己项目打包所有的报错:

部分关键信息已打码 

Error: C:\Users\<用户名>\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.3.2\Bin\makensis.exe exited with code 1
Output:
Command line defined: "APP_ID=com.example.yourapp"
Command line defined: "APP_GUID=1fb8a7aa-e784-579d-a981-2142d5507b97"
Command line defined: "UNINSTALL_APP_KEY=1fb8a7aa-e784-579d-a981-2142d5507b97"
Command line defined: "PRODUCT_NAME=qiqi"
Command line defined: "PRODUCT_FILENAME=qiqi"
Command line defined: "APP_FILENAME=qiqi"
Command line defined: "APP_DESCRIPTION=An electron-vue project"
Command line defined: "VERSION=1.0.0"
Command line defined: "PROJECT_DIR=D:\work\qiqi\qiqi\qiqi"
Command line defined: "BUILD_RESOURCES_DIR=D:\work\qiqi\qiqi\qiqi\build"
Command line defined: "APP_PACKAGE_NAME=qiqi"
Command line defined: "APP_64=D:\work\qiqi\qiqi\qiqi\build\qiqi-1.0.0-x64.nsis.7z"
Command line defined: "APP_64_NAME=qiqi-1.0.0-x64.nsis.7z"
Command line defined: "APP_64_HASH=F2A8803E3BCAA3AF180102FACF726803F6E1188030AE568DE89265C0C4EAA26344B87EBEC7580A25D4D9A863F1417E4A9CEC0814993D2622D234B2D49F667021"
Command line defined: "COMPANY_NAME=guhongxin"
Command line defined: "APP_PRODUCT_FILENAME=qiqi"
Command line defined: "APP_INSTALLER_STORE_FILE=qiqi-updater\installer.exe"
Command line defined: "COMPRESSION_METHOD=7z"
Command line defined: "ONE_CLICK"
Command line defined: "RUN_AFTER_FINISH"
Command line defined: "SHORTCUT_NAME=qiqi"
Command line defined: "UNINSTALL_DISPLAY_NAME=qiqi 1.0.0"
Command line defined: "ESTIMATED_SIZE=233635"
Command line defined: "COMPRESS=auto"
Command line defined: "UNINSTALLER_OUT_FILE=D:\work\qiqi\qiqi\qiqi\build\.__uninstaller-nsis-qiqi.exe"
Processing config: C:\Users\<用户名>\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.3.2\nsisconf.nsh
Processing script file: "<stdin>" (UTF8)

Processed 1 file, 10 command line commands, writing output (x86-unicode):

Output: "D:\work\qiqi\qiqi\qiqi\build\qiqi Setup 1.0.0.exe"

Error output:
Can't open output file
Error - aborting creation process

    at ChildProcess.<anonymous> (D:\work\qiqi\qiqi\qiqi\node_modules\builder-util\src\util.ts:244:14)
    at Object.onceWrapper (events.js:520:26)
    at ChildProcess.emit (events.js:400:28)
    at maybeClose (internal/child_process.js:1055:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! qiqi@1.0.0 build: `node .electron-vue/build.js && electron-builder`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the qiqi@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\<用户名>\AppData\Roaming\npm-cache\_logs\2023-10-19T01_26_29_612Z-debug.log

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值