使用电子生成器构建便携式.exe时,如何修复“ npm dist”失败

时间:2019-07-12 19:19:48

标签: node.js electron package.json electron-builder

使用电子生成器运行“ npm dist”时,构建始终会失败。

我已经尝试根据我在各种StackOverflow帖子和官方电子构建配置文档中看到的一些配置技巧,以多种方式修改我的package.json,但每次仍然失败。

package.json:

{
  "name": "app",
  "version": "0.3.0",
  "license": "None",
  "description": "Dummy description",
  "author": "Author",
  "main": "./main.js",
  "scripts": {
    "postinstall": "install-app-deps",
    "start": "electron .",
    "pack": "electron-builder --dir",
    "dist": "electron-builder"
  },
  "electron-builder": {
    "build": {
      "productName": "App Name",
      "appId": "app",
      "win": {
        "target": [
          "nsis",
          "portable"
        ],
        "icon": "build/icon.png"
      },
      "portable": {
        "unicode": false,
        "artifactName": "app_portable.exe"
      },
      "nsis": {
        "unicode": false,
        "artifactName": "app_installer.exe"
      }
    }
  },
  "dependencies": {
    "easy-soap-request": "^2.6.0",
    "jquery": "^3.4.1",
    "mssql": "latest",
    "xml-formatter": "^1.1.0"
  },
  "devDependencies": {
    "electron": "^5.0.6",
    "electron-builder": "latest",
    "eslint": "^6.0.1"
  }
}

我得到的错误是:

Error: C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-bin\win\x64\app-builder.exe exited with code 1
    at ChildProcess.<anonymous> (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\builder-util\src\util.ts:244:14)
    at Object.onceWrapper (events.js:284:20)
    at ChildProcess.emit (events.js:196:13)
    at maybeClose (internal/child_process.js:1011:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:268:5)
From previous event:
    at WinPackager.resolveIcon (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\platformPackager.ts:594:101)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\platformPackager.ts:573:31
    at Generator.next (<anonymous>)
From previous event:
    at WinPackager.getOrConvertIcon (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\platformPackager.ts:572:54)
    at Lazy.<anonymous> (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\winPackager.ts:79:43)
    at Lazy.get value [as value] (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\lazy-val\src\main.ts:18:25)
    at WinPackager.getIconPath (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\winPackager.ts:190:27)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\winPackager.ts:287:33
    at Generator.next (<anonymous>)
From previous event:
    at WinPackager.signAndEditResources (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\winPackager.ts:260:158)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\winPackager.ts:363:21
    at go$readdir$cb (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\graceful-fs\graceful-fs.js:162:14)
    at FSReqCallback.oncomplete (fs.js:136:23)
From previous event:
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\winPackager.ts:361:27
    at Generator.next (<anonymous>)
From previous event:
    at WinPackager.signApp (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\winPackager.ts:355:73)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\platformPackager.ts:250:16
    at Generator.next (<anonymous>)
    at processImmediate (internal/timers.js:439:21)
From previous event:
    at WinPackager.doPack (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\platformPackager.ts:167:165)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\platformPackager.ts:113:16
    at Generator.next (<anonymous>)
From previous event:
    at WinPackager.pack (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\platformPackager.ts:111:95)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\packager.ts:430:24
    at Generator.next (<anonymous>)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\fs-extra\lib\mkdirs\mkdirs.js:56:16
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\graceful-fs\polyfills.js:285:20
    at FSReqCallback.oncomplete (fs.js:149:5)
From previous event:
    at Packager.doBuild (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\packager.ts:396:24)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\packager.ts:366:57
    at Generator.next (<anonymous>)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\graceful-fs\graceful-fs.js:111:16
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\graceful-fs\graceful-fs.js:45:10
    at FSReqCallback.oncomplete (fs.js:136:23)
From previous event:
    at Packager._build (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\packager.ts:335:133)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\packager.ts:331:23
    at Generator.next (<anonymous>)
    at processImmediate (internal/timers.js:439:21)
From previous event:
    at Packager.build (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\packager.ts:288:14)
    at build (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\node_modules\app-builder-lib\src\index.ts:59:28)
    at build (C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\src\builder.ts:228:10)
    at C:\Users\joey\AppData\Roaming\npm\node_modules\electron-builder\src\cli\cli.ts:46:19
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app@0.3.0 dist: `electron-builder`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app@0.3.0 dist 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\joey\AppData\Roaming\npm-cache\_logs\2019-07-12T19_07_00_599Z-debug.log
The terminal process terminated with exit code: 1

我不知道该怎么办。当我将其打包为安装程序时,它曾经可以工作,但现在我需要将其作为便携式exe。任何帮助,将不胜感激。谢谢!

1 个答案:

答案 0 :(得分:0)

好吧,显然我只需要再次运行npm install。