Publishing an electron application fails with: Error!! TypeError: Cannot read property 'provider' of null

Publishing an electron application fails with: Error!! TypeError: Cannot read property 'provider' of null

我正在尝试发布我的 Electron 应用程序,因此,我将发布添加到 package.json,现在它看起来像这样:

{
  "devDependencies": {
    "electron": "^1.7.4",
    "electron-builder": "^11.5.1"
  },
  "dependencies": {
    "electron-publisher-s3": "^19.16.0"
  },
  "build": {
    "appId": "tech.dashman.Dashman",
    "win": {
      "icon": "build/icon.ico"
    },
    "publish": [
      {
        "provider": "s3",
        "bucket": "dashman-app",
        "path": "/",
        "acl": "public-read"
      }
    ]
  }
}

我有一个单独的app/package.json。当我尝试通过 运行

发布时
node build\dist.js

我明白了

Rebuilding native production dependencies for win32:ia32
Packaging for win32 ia32 using electron 1.7.4 to dist\win-ia32-unpacked
Copying Dashman.exe to Dashman.scr
Done copying Dashman.exe to Dashman.scr
Packaging NSIS installer for arch ia32
Building NSIS installer
Error!! TypeError: Cannot read property 'provider' of null
    at C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\src\publish\PublishManager.ts:181:22
    at Generator.next (<anonymous>)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)
From previous event:
    at writeUpdateInfo (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\out\publish\PublishManager.js:115:22)
    at C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\src\publish\PublishManager.ts:103:22
From previous event:
    at PublishManager.artifactCreated (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\out\publish\PublishManager.js:278:11)
    at EventEmitter.PublishManager.packager.artifactCreated.event (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\src\publish\PublishManager.ts:72:57)
    at emitOne (events.js:101:20)
    at EventEmitter.emit (events.js:191:7)
    at Packager.dispatchArtifactCreated (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\src\packager.ts:78:23)
    at WinPackager.dispatchArtifactCreated (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\src\platformPackager.ts:88:15)
    at C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\src\targets\nsis.ts:216:14
From previous event:
    at NsisTarget.buildInstaller (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\out\targets\nsis.js:260:11)
    at C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\src\targets\nsis.ts:59:18
    at Generator.next (<anonymous>)
From previous event:
    at NsisTarget.finishBuild (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\out\targets\nsis.js:133:11)
    at C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\src\packager.ts:179:31
From previous event:
    at Packager.doBuild (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\out\packager.js:299:11)
    at C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\src\packager.ts:143:38
    at Generator.next (<anonymous>)
    at runCallback (timers.js:672:20)
    at tryOnImmediate (timers.js:645:5)
    at processImmediate [as _immediateCallback] (timers.js:617:5)
From previous event:
    at Packager.build (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\out\packager.js:251:11)
    at Object.<anonymous> (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\src\builder.ts:214:40)
    at Generator.next (<anonymous>)
From previous event:
    at Object.build (C:\Users\pupeno\Documents\Dashman\clients\node_modules\electron-builder\out\builder.js:63:21)
    at Object.<anonymous> (C:\Users\pupeno\Documents\Dashman\clients\build\dist.js:11:9)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:423:7)
    at startup (bootstrap_node.js:147:9)
    at bootstrap_node.js:538:3

build\dist.js 包含这样的内容:

const builder = require("electron-builder");
const Platform = builder.Platform;
const Arch = builder.Arch;

const fs = require("fs");

builder.build({
    targets: Platform.WINDOWS.createTarget("nsis", Arch.ia32),
    config: {
        "afterPack": () => { do_some_stuf()});
        }
    }
}).then(() => {
    console.log("Done!");
}).catch((error) => {
    console.log("Error!!", error);
});

知道为什么我会收到该错误吗?

问题似乎在于我是 运行 一个非常旧版本的 electron-builder。我升级了,现在可以用了。