编译一个 electron 项目的时候报错,报错如下:
bash
⨯ C:\Users\zhengxm\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
Output:
Command line defined: "APP_ID=com.aaaaa"
Command line defined: "APP_GUID=e772aab9-188f-574a-8180-e2a77ae5c2fe"
Command line defined: "UNINSTALL_APP_KEY=e772aab9-188f-574a-8180-e2a77ae5c2fe"
Command line defined: "PRODUCT_NAME=������Դ���ݴ���ϵͳ"
Command line defined: "PRODUCT_FILENAME=������Դ���ݴ���ϵͳ"
Command line defined: "APP_FILENAME=aaaaa"
Command line defined: "APP_DESCRIPTION=������Դ���ݴ���ϵͳ"
Command line defined: "VERSION=1.0.0"
Command line defined: "PROJECT_DIR=D:\vue\aaaaa"
Command line defined: "BUILD_RESOURCES_DIR=D:\vue\aaaaa\build"
Command line defined: "APP_PACKAGE_NAME=a1"
Command line defined: "MUI_ICON=D:\vue\aaaaa\build\icon.ico"
Command line defined: "MUI_UNICON=D:\vue\aaaaa\build\icon.ico"
Command line defined: "APP_64=D:\vue\aaaaa\dist\aaaaa-1.0.0-x64.nsis.7z"
Command line defined: "APP_64_NAME=aaaaa-1.0.0-x64.nsis.7z"
Command line defined: "APP_64_HASH=020B197D516F7DA9917AD3E14D0C016F135F0F964CA8D576AAA4F92C0A7C0C76E5B79FD96A8F72470A4BB88845CFAFD4CCB93141DA9157046C4E432030178DA7"
Command line defined: "COMPANY_NAME=OpenAI"
Command line defined: "APP_PRODUCT_FILENAME=������Դ���ݴ���ϵͳ"
Command line defined: "APP_INSTALLER_STORE_FILE=aaaaa-updater\installer.exe"
Command line defined: "COMPRESSION_METHOD=7z"
Command line defined: "MULTIUSER_INSTALLMODE_ALLOW_ELEVATION"
Command line defined: "INSTALL_MODE_PER_ALL_USERS"
Command line defined: "INSTALL_MODE_PER_ALL_USERS_REQUIRED"
Command line defined: "allowToChangeInstallationDirectory"
Command line defined: "SHORTCUT_NAME=������Դ���ݴ���ϵͳ"
Command line defined: "UNINSTALL_DISPLAY_NAME=������Դ���ݴ���ϵͳ"
Command line defined: "RECREATE_DESKTOP_SHORTCUT"
Command line defined: "MUI_WELCOMEFINISHPAGE_BITMAP=${NSISDIR}\Contrib\Graphics\Wizard\nsis3-metro.bmp"
Command line defined: "MUI_UNWELCOMEFINISHPAGE_BITMAP=${NSISDIR}\Contrib\Graphics\Wizard\nsis3-metro.bmp"
Command line defined: "ESTIMATED_SIZE=6658332"
Command line defined: "COMPRESS=auto"
Command line defined: "UNINSTALLER_OUT_FILE=D:\vue\aaaaa\dist\__uninstaller-nsis-aaaaa.exe"
Processing config: C:\Users\aaaaa\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\nsisconf.nsh
Processing script file: "<stdin>" (ACP)
Error output:
File: failed creating mmap of "D:\vue\aaaaa\dist\aaaaa-1.7.7-x64.nsis.7z"
Error in macro x64_app_files on macroline 1
Error in macro compute_files_for_current_arch on macroline 7
Error in macro extractEmbeddedAppPackage on macroline 8
Error in macro installApplicationFiles on macroline 79
!include: error in script: "installSection.nsh" on line 63
Error in script "<stdin>" on line 192 -- aborting creation process
failedTask=build stackTrace=Error: C:\Users\aaaaa\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe exited with code ERR_ELECTRON_BUILDER_CANNOT_EXECUTE
用 AI 去查
用 AI 去查都会说是权限,或者空间不够
- 检查文件 :
- 确认
D:\vue\aaaaa\dist\aaaaa-1.7.7-x64.nsis.7z
文件是否存在且未损坏。 - 尝试手动解压该文件,看是否有问题。
- 确认
- 检查权限 :
- 确保你有足够的权限来读取和写入该文件。
- 尝试以管理员身份运行构建脚本或 IDE。
- 检查磁盘空间 :
- 确认你的磁盘上有足够的空间来执行构建过程。
- 清理缓存 :
- 清理 NSIS 或 Electron Builder 的缓存,然后重新尝试构建。
- 有时候,缓存中的旧数据或损坏的数据会导致此类问题。
- 更新工具 :
- 确保你使用的 NSIS 和 Electron Builder 是最新版本。
- 有时候,软件的旧版本可能包含已知的错误,这些错误可能在新版本中被修复。
- 查看日志和文档 :
- 仔细检查 Electron Builder 和 NSIS 的日志,看是否有更详细的错误信息。
- 查阅相关文档,看是否有针对此类问题的官方解决方案或建议。
- 搜索类似问题 :
- 在网络上搜索类似的错误信息和解决方案,特别是在像 GitHub、Stack Overflow 这样的开发者社区中。
实际上就是 3.0.4.1 的 nsis 这个包不支持打包超过 2G 的可执行文件,导致electron-builder进行7z压缩时失败,不过这个在 windows 上好像才会出现
解决方案就是替换目录下 C:\Users\aaaaa\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\Bin\makensis.exe
里面的文件,文件评论发 email 。