我已经创建了一个应用程序与离子角。我试图建立它使用电子和创建一个安装程序的应用程序。我已经运行ionic build
-〉npm i @capacitor-community/electron --save-dev
-〉npx cap add @capacitor-community/electron
在创建的电子文件夹中,我向package.json
添加了一些代码:
{
"name": "financeapp",
"productName":"Finance Monitor",
"version": "1.0.0",
"description": "An Amazing Capacitor App",
"author": {
"name": "",
"email": ""
},
"repository": {
"type": "git",
"url": ""
},
"license": "MIT",
"main": "build/src/index.js",
"scripts": {
"build": "tsc && electron-rebuild",
"electron:start-live": "node ./live-runner.js",
"electron:start": "npm run build && electron --inspect=5858 ./",
"electron:pack": "npm run build && electron-builder build --dir -c ./electron-builder.config.json",
"electron:make": "npm run build && electron-builder build -c ./electron-builder.config.json -p always"
},
"dependencies": {
"@capacitor-community/electron": "^4.1.0",
"chokidar": "~3.5.2",
"electron-is-dev": "~2.0.0",
"electron-serve": "~1.1.0",
"electron-unhandled": "~3.0.2",
"electron-updater": "~4.3.9",
"electron-window-state": "~5.0.3"
},
"devDependencies": {
"electron": "^14.0.0",
"electron-builder": "~22.11.7",
"electron-rebuild": "^3.2.3",
"typescript": "~4.3.5"
},
"keywords": [
"capacitor",
"electron"
]
}
我的electron-builder.config.json
:
{
"appId": "com.yourdoamnin.yourapp",
"directories": {
"buildResources": "resources"
},
"files": [
"assets/**/*",
"build/**/*",
"capacitor.config.*",
"app/**/*"
],
"publish": {
"provider": "github",
"publishAutoUpdate": false
},
"nsis": {
"allowElevation": true,
"oneClick": false,
"allowToChangeInstallationDirectory": true
},
"win": {
"target": "nsis",
"icon": "assets/appIcon.ico"
},
"mac": {
"category": "your.app.category.type",
"target": "dmg"
}
}
然后,我转到电子文件夹目录并运行:npm run electron:make
,但它只创建了一个win_unpack文件夹,而没有安装程序,并显示以下错误:
⨯ Cannot detect repository by .git/config. Please specify "repository" in the package.json (https://docs.npmjs.com/files/package.json#repository).
Please see https://electron.build/configuration/publish failedTask=build stackTrace=Error: Cannot detect repository by .git/config. Please specify "repository" in the package.json (https://docs.npmjs.com/files/package.json#repository).
我在这里做错了什么?我如何创建安装程序?
1条答案
按热度按时间i34xakig1#
Capacitor 3 @capacitor-community/electron有内置的发布功能,如果使用Github,需要指定一个repo并添加一个GITHUB_TOKEN。如果不想自动发布,只需从electron-builder.config.json中删除publish部分。它从第12行开始。