I am trying to run a sample app in Windows using Electron. The creation/use of desktop apps seems to be available but lacks up to date documentation.
I performed the following:
ionic start test blank --capacitor --type react
cd test
npm install @capacitor-community/electron
ionic cap add electron
ionic cap build electron
I get the following error on the build command:
...
> capacitor.cmd open electron
[capacitor] - Opening Electron platform
[capacitor] - Opening Electron platform: start 🚀
[capacitor] i Opening Electron platform: start 🚀
[capacitor] - Opening Electron platform: building electron app
[capacitor] i Opening Electron platform: building electron app
[capacitor] - Opening Electron platform: running electron app
[capacitor] Error: undefined
[capacitor] Ă— Opening Electron platform:
[capacitor] node:internal/process/promises:288
[capacitor] triggerUncaughtException(err, true /* fromPromise */);
[capacitor] ^
[capacitor]
[capacitor] [UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "
[capacitor] > test@1.0.0 electron:start-live
[capacitor] > node ./live-runner.js
[capacitor]
[capacitor] ".] {js v18.20.4n' (node:internal/modules/cjs/loader:1203:32) {:1422:10)r.js:75:3)
[capacitor] code: 'ERR_UNHANDLED_REJECTION'
[capacitor] }
[capacitor]
[capacitor] Node.js v18.20.4
I thought it might have been a problem with my version of NodeJS so I also tried 20.18.0–I get the same error.
If I try to run electron using ionic cap run electron
I get the following error:
[ERROR] No devices or emulators found
I also ran npx cap doctor electron
and it claims electron is an “invalid platform”:
Capacitor Doctor
Latest Dependencies:
@capacitor/cli: 6.1.2
@capacitor/core: 6.1.2
@capacitor/android: 6.1.2
@capacitor/ios: 6.1.2
Installed Dependencies:
@capacitor/ios: not installed
@capacitor/cli: 6.1.2
@capacitor/android: 6.1.2
@capacitor/core: 6.1.2
[error] Invalid platform: electron
I reran npx cap add electron
and it says Ă— Adding Electron platform: Electron platform already exists.
. So it is all a bit confusing.
Any ideas what I could be doing wrong? Is Electron no longer supported? If not, is PWA the only alternative?