提问者:小点点

“build”不被识别为内部或外部命令-使用ElectronJS/Electronic-Builder


我最近和Electron-Builder一起将我的electronJS应用程序更新到了更高的版本。我用“NPM Start”运行这个应用程序没有问题,但是当我尝试用electron-builder构建它时,我在运行“NPM run Dist”时遇到以下错误:

$npm运行dist

MyApp@1.0.0 dist C:\Projects\MyApp build

“build”不能识别为内部或外部命令、可操作程序或批处理文件。npm错误!代码ELIFECYCLE npm错误!错误1 npm错误!MyApp@1.0.0 dist:buildnpm错误!退出状态%1 npm错误!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


共1个答案

匿名用户

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

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

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