Angular 5 Electron-Packager在第二次修剪时失败 - 生产'

时间:2018-03-27 14:11:16

标签: node.js angular npm electron angular-cli

我试图使用电子包装器打包Angular 5 CLI应用程序。

该应用构建并打开' ng build --prod && electron .'命令,但在尝试使用' electron-packager . platform=win32'打包时,我收到以下错误:

  

命令失败:npm prune --production

     

npm ERR!无法阅读财产' 0'未定义的

     

npm ERR!可以在以下位置找到此运行的完整日志:C:\ Users \ Nick Cook \ AppData \ Roaming \ npm-cache_logs \ 2018-03-27T13_37_39_477Z-debug.log

我在尝试使用' npm install -g npm'之前更新到npm 5.8.0。

的package.json:

{
  "name": "angular-5-firebase",
  "version": "0.0.0",
  "license": "MIT",
  "main": "main.js",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "deploy": "ng build --prod && firebase deploy",
    "electron": "electron .",
    "electron-build": "ng build --prod && electron ."
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/cdk": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/flex-layout": "^5.0.0-beta.13",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/material": "^5.2.4",
    "@angular/material-moment-adapter": "^5.2.4",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@types/es6-promise": "^3.3.0",
    "angularfire2": "^5.0.0-rc.6",
    "core-js": "^2.4.1",
    "electron": "^1.8.4",
    "firebase": "^4.12.0",
    "hammerjs": "^2.0.8",
    "moment": "^2.21.0",
    "ngx-electron": "^1.0.4",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular/cli": "1.6.6",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/faker": "^4.1.2",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "faker": "^4.1.0",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  },
  "repository": "...",
  "author": "..."

}

1 个答案:

答案 0 :(得分:1)

运行电子包装机的基本格式为:

electron-packager <sourcedir> <appname> --platform=<platform> --arch=<arch> [optional flags...]

这意味着您必须填写平台和体系结构类型,除非您指定--all标志。如果您指定标志电子包装商将为目标平台/架构的所有有效组合创建捆绑包。

因此,您需要命名应用程序,并将--arch标志添加到命令中。

尝试运行:electron-packager . YourApplicationName --platform=win32 --arch=ia32

注意:它必须在项目的根目录下运行,否则您将不得不通过更改.

来指定源目录。

我最近的一个应用程序中的package.json示例:

  "name": "my-app",
  "version": "0.0.0",
  "main": "main.js",
  "scripts": {
    "electron": "ng build --base-href ./ && electron .",
    "electron-package": "ng build --prod && electron-packager . ApplicationName--platform=win32 --arch=ia32 --overwrite",
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.1.10",
    "@angular/cdk": "^7.3.0",
    "@angular/common": "^6.0.0",
    "@angular/compiler": "^6.0.0",
    "@angular/core": "^6.0.0",
    "@angular/flex-layout": "^5.0.0-beta.14",
    "@angular/forms": "^6.0.0",
    "@angular/http": "^6.0.0",
    "@angular/material": "^7.3.0",
    "@angular/platform-browser": "^6.0.0",
    "@angular/platform-browser-dynamic": "^6.0.0",
    "@angular/router": "^6.0.0",
    "angular": "^1.7.6",
    "core-js": "^2.5.4",
    "hammerjs": "^2.0.8",
    "ngx-electron": "^2.1.1",
    "rxjs": "^5.6.0-forward-compat.5",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.6.0",
    "@angular/cli": "^7.2.3",
    "@angular/compiler-cli": "^6.0.0",
    "@angular/language-service": "^6.0.0",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "electron": "^4.0.3",
    "electron-packager": "^13.0.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "^5.4.2",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1",
    "typescript": "^2.9.2"
  }
}

文档:https://github.com/electron-userland/electron-packager