【问题标题】:Build not found error when trying to create an installer for my electron app尝试为我的电子应用程序创建安装程序时未找到构建错误
【发布时间】:2016-12-21 00:27:48
【问题描述】:

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

在我的电脑上输入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/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"
  }
}

我使用的是 Windows 10,并通过 bash 执行命令

【问题讨论】:

    标签: javascript node.js bash electron electron-builder


    【解决方案1】:

    我正在关注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"
      },
    

    【讨论】:

      【解决方案2】:

      electron-builder 未安装。你不需要electron-installer-squirrel-windowselectron-packager,- 删除它和npm install electron-builder --save-dev

      【讨论】:

      • 谢谢你的工作!出于好奇,为什么 npm run dist 只生成 linux 文件夹,我想创建 windows 安装程序,但它仅使用电子 1.3.3 为平台 linux x64 打包到 dist/linux
      • build -mwl(为 MacOS、Windows 和 Linux 构建应用程序)。请看github.com/electron-userland/electron-builder/wiki/…
      猜你喜欢
      • 1970-01-01
      • 2022-07-30
      • 2019-03-26
      • 2018-04-02
      • 1970-01-01
      • 2018-03-23
      • 2020-11-02
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多