Zheng Dong
Zheng Dong

Reputation: 1

using capacitor-community/electron to create desktop app with an installer, but installer missing

I've created an app with ionic angular. I'm trying to build it using electron and to create an installer for the app. I've run ionic build -> npm i @capacitor-community/electron --save-dev -> npx cap add @capacitor-community/electron

In the electron folder created, I've added some code to 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"
  ]
}


myelectron-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"
  }
}

I then go to the electron folder directory and run: npm run electron:make, but it only creates a win_unpack folder without an installer and it shows this error:

 ⨯ 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).

What am I doing wrong here? How do I create the installer?

Upvotes: 0

Views: 1755

Answers (1)

eldiren
eldiren

Reputation: 11

Capacitor 3 @capacitor-community/electron has publishing built in and wants you to to specify a repo and add a GITHUB_TOKEN if using Github. If you don't want it to publish automatically just remove the publish section from electron-builder.config.json. It starts somewhere around line 12.

Upvotes: 1

Related Questions