【问题标题】:'build' is not recognized as an internal or external command - Using ElectronJS / electron-builder'build' 不被识别为内部或外部命令 - 使用 ElectronJS / electron-builder
【发布时间】:2020-03-30 08:09:26
【问题描述】:

我最近与 electron-builder 一起将我的 electronJS 应用程序更新到了更高版本。 我使用“npm start”运行应用程序没有问题,但是当我尝试使用 electron-builder 构建它时,运行“npm run dist”时出现以下错误:

$ npm run dist

myapp@1.0.0 dist C:\Projects\myapp 构建

'build' 不是内部或外部命令,可操作 程序或批处理文件。 npm 错误!代码 ELIFECYCLE npm 错误!错误号 1 npm 呃! myapp@1.0.0 dist: build npm ERR!退出状态 1 npm ERR! npm 呃!在 myapp@1.0.0 dist 脚本中失败。 npm 错误!这大概是 npm 没问题。可能有额外的日志输出 以上。

npm 错误!可以在以下位置找到此运行的完整日志:npm ERR!
C:\Users\User\AppData\Roaming\npm-cache_logs\2019-12-05T11_35_33_988Z-debug.log

package.json:

{
  "name": "myapp",
  "version": "1.1.0",
  "description": "none",
  "main": "main.js",
  "scripts": {
    "start": "electron .",
    "dist": "build",
    "postinstall": "electron-builder install-app-deps"
  },
  "build": {
    "appId": "Myapp.com",
    "asar": true,
    "asarUnpack": [
      "configuration/**/*",
      "output/**/*",
      "appdata/**/*",
      "node_modules/easy-pdf-merge/**/*"
    ]
  },
  "repository": {
    "type": "git",
    "url": ""
  },
  "author": "",
  "license": "ISC",
  "homepage": "",
  "dependencies": {
    "axios": "^0.19.0",
    "cryptr": "^6.0.1",
    "easy-pdf-merge": "^0.2.0",
    "edit-json-file": "^1.2.0",
    "electron-log": "^3.0.9",
    "electron-updater": "^4.2.0",
    "eslint": "^5.12.0",
    "exceljs": "^1.6.3",
    "googleapis": "^27.0.0",
    "mustache": "^3.0.1",
    "node-localstorage": "^2.1.5",
    "npm": "^6.5.0",
    "pdf-table-extractor": "^1.0.3",
    "popper.js": "^1.15.0",
    "sqlite3": "^4.0.4",
    "tippy.js": "^4.3.4",
    "universal-analytics": "^0.4.20",
    "uuid": "^3.3.3",
    "webpack": "^4.28.0",
    "winston": "^3.1.0"
  },
  "devDependencies": {
    "electron": "^7.1.3",
    "electron-builder": "^21.2.0"
  }
}

节点版本:12.13.1 npm 版本:6.12.1

【问题讨论】:

    标签: npm electron electron-builder


    【解决方案1】:

    更新后我错过了 package.json 中的以下内容:

    "scripts": {
      "pack": "electron-builder --dir",
      "dist": "electron-builder"
    }
    

    据此:https://www.npmjs.com/package/electron-builder

    【讨论】:

      【解决方案2】:

      我遇到了类似的问题,并通过 package.json

      中的以下命令解决了
      "electron-pack": "electron-builder --win -p always"
      

      之后-

      npm run electron-pack
      

      (或)

      yarn electron-pack
      

      它将创建一个安装程序。

      【讨论】:

        猜你喜欢
        • 2017-12-19
        • 2021-09-15
        • 2021-02-08
        • 1970-01-01
        • 2014-10-21
        • 2014-02-08
        • 2017-08-22
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多