尝试为我的电子应用程序创建安装程序时构建未找到错误

Build not found error when trying to create an installer for my electron app

我正在尝试为我的电子应用程序创建一个 window 安装程序(这样它就可以 运行 在任何 windows 计算机上作为一个独立的应用程序)使用 electron-builder https://www.npmjs.com/package/electron-builder

在我的电脑上输入 npm run dist 时,我 运行 出现以下错误。

sh: 1: build: not found

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dist"
npm ERR! node v6.2.2
npm ERR! npm  v3.9.5
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! <NAME>@0.0.0 dist: `build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the <NAME>@0.0.0 dist script 'build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the <NAME>,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     build

下面是我的 package.json 文件的样子

{
  "name": "<NAME>",
  "version": "0.0.0",
  "description": "[...]",
  "main": "index.js",
  "build": {
    "appId": "test.321",
    "app-category-type": "your.app.category.type",
    "win": {
      "iconUrl": "http://cdn.sstatic.net/Sites/Whosebug/img/apple-touch-icon.png"
    }
  },
  "scripts": {
    "start": "electron main.js",
    "postinstall": "install-app-deps",
    "pack": "build --dir",
    "dist": "build"
  },
  "author": "<NAME> <jon@gmail.com>",
  "license": "ISC",
  "devDependencies": {
    "electron": "^1.3.3",
    "electron-installer-squirrel-windows": "^1.3.0",
    "electron-packager": "^7.5.1"
  }
}

我正在使用 windows 10,并通过 bash

执行命令

electron-builder 未安装。您不需要 electron-installer-squirrel-windowselectron-packager,— 将其删除并 npm install electron-builder --save-dev

我正在按照 this blogpost 构建它,但我遇到了同样的问题,我解决了用 electron-builder 命令替换 build 并删除过时的 category 字段名称.

"scripts": {
    "postinstall": "install-app-deps",
    "start": "npm install && electron .",
    "test": "echo \"Error: no test specified\" && exit 1",
    "pack": "electron-builder --dir",
    "dist": "electron-builder"
  },