Adding icon in electron app throw Error: spawn UNKNOWN

Adding icon in electron app throw Error: spawn UNKNOWN

电子-builder.yml

appId: com
productName: ABC

asar: false

directories:
  buildResources: dist-assets/
  output: dist/

files:
  - package.json
  - init.js
  - build/
  - node_modules/

win:
  target: nsis
  # icon: "app/client/assets/images/icon.ico"


当我使用上述文件构建代码时,它工作正常并创建了 exe 和 NSIS 安装程序

但如果我取消注释图标行,它会创建一个 exe 文件,但在构建时,NSIS 会抛出以下错误(构建目标时出错=nsis)

• writing effective config  file=dist\builder-effective-config.yaml
  • rebuilding native dependencies  dependencies=better-sqlite3@7.5.0 platform=win32 arch=x64
  • install prebuilt binary  name=better-sqlite3 version=7.5.0 platform=win32 arch=x64 napi=
  • packaging       platform=win32 arch=x64 electron=15.3.5 appOutDir=dist\win-unpacked
  • building        target=nsis file=dist\ABC Setup 1.0.0.exe archs=x64 oneClick=true perMachine=false  
[15:52:45] 'builder-win' errored after 1.98 min
[15:52:45] Error: spawn UNKNOWN
    at ChildProcess.spawn (internal/child_process.js:403:11)
    at spawn (child_process.js:580:9)
    at Object.execFile (child_process.js:248:17)
    at C:\Users\hp\Desktop\PROJECT\GitHub\ABC\node_modules\builder-util\src\util.ts:94:5
    at new Promise (<anonymous>)
    at Object.exec (C:\Users\hp\Desktop\PROJECT\GitHub\ABC\node_modules\builder-util\src\util.ts:93:10)
    at Object.execWine (C:\Users\hp\Desktop\PROJECT\GitHub\ABC\node_modules\app-builder-lib\src\wine.ts:11:12)
    at NsisTarget.computeScriptAndSignUninstaller (C:\Users\hp\Desktop\PROJECT\GitHub\ABC\node_modules\app-builder-lib\src\targets\nsis\NsisTarget.ts:387:13)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at NsisTarget.buildInstaller (C:\Users\hp\Desktop\PROJECT\GitHub\ABC\node_modules\app-builder-lib\src\targets\nsis\NsisTarget.ts:306:9)
    at NsisTarget.finishBuild (C:\Users\hp\Desktop\PROJECT\GitHub\ABC\node_modules\app-builder-lib\src\targets\nsis\NsisTarget.ts:131:9)
    at async Promise.all (index 1)
    at AsyncTaskManager.awaitTasks (C:\Users\hp\Desktop\PROJECT\GitHub\ABC\node_modules\builder-util\src\asyncTaskManager.ts:65:25)
    at Packager.doBuild (C:\Users\hp\Desktop\PROJECT\GitHub\ABC\node_modules\app-builder-lib\src\packager.ts:453:5)
    at Object.executeFinally (C:\Users\hp\Desktop\PROJECT\GitHub\ABC\node_modules\builder-util\src\promise.ts:12:14)
    at Packager._build (C:\Users\hp\Desktop\PROJECT\GitHub\ABC\node_modules\app-builder-lib\src\packager.ts:376:31)

图标 256X256, 10.1kb

这是图标引起的吗?

如果是这样,我应该检查什么图标?

如果不是什么会导致此错误?

谢谢。

我相信我曾经遇到过这个错误,简单的解决方法是更换图标,因为我的图标不知何故已损坏。 只需 re-create .ico 图标并添加即可。

有趣的是事情是如何自行崩溃的,这不是你的错。