gpt4 book ai didi

node.js - Angular 5 Electron-Packager在 'npm prune --production'失败

转载 作者:行者123 更新时间:2023-12-03 12:35:31 31 4
gpt4 key购买 nike

我正在尝试使用 Electron 打包程序打包Angular 5 CLI应用程序。
该应用程序会使用“ng build --prod && electron .”命令生成并打开,但是当尝试使用“electron-packager . platform=win32”将其打包时,出现以下错误:

Command failed: npm prune --production

npm ERR! Cannot read property '0' of undefined

npm ERR! A complete log of this run can be found in: 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": "..."
}

最佳答案

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

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

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

因此,您需要命名您的应用程序,并将 --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

关于node.js - Angular 5 Electron-Packager在 'npm prune --production'失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49515196/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com