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

Joh*_*ohn 1 javascript bash node.js electron electron-builder

我正在尝试使用电子构建器为我的电子应用程序创建一个窗口安装程序(以便它可以作为独立应用程序在任何 Windows 计算机上运行)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
Run Code Online (Sandbox Code Playgroud)

下面是我的 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/stackoverflow/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"
  }
}
Run Code Online (Sandbox Code Playgroud)

我正在使用 Windows 10,并通过 bash 执行命令

erh*_*hun 6

我在下面我这篇文章,以建立它和我有同样的问题,我解决它来代替buildelectron-builder指挥也删除过时的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"
  },
Run Code Online (Sandbox Code Playgroud)


dev*_*lar 5

electron-builder未安装。你不需要electron-installer-squirrel-windowsand electron-packager, — 删除它 andnpm install electron-builder --save-dev

  • `build -mwl`(为 MacOS、Windows 和 Linux 构建应用程序)。请参阅 https://github.com/electron-userland/electron-builder/wiki/Multi-Platform-Build (2认同)