And I’ve followed these steps starting from a new brand app:
ionic start myPhotoGallery my-first-app --type=angular --capacitor
cd myPhotoGallery
npm install ngx-electron electron
npm install electron-packager --save-dev
ionic build
npx cap add electron
npx cap open electron
However the last command doesn’t nothing and I have not an Electron folder in the project.
I’m using:
Sorry, yes it is true, with the community edition if I execute these steps:
ionic start myPhotoGallery my-first-app --type=angular --capacitor
cd myPhotoGallery
npm i @capacitor-community/electron
ionic build
npx cap add @capacitor-community/electron
cd electron
npm run build
npm run electron:start-live
npm run electron:pack
The run build command fails with this error:
>npm run build
> Photo Gallery Cap Ng@1.0.0 build
> tsc && electron-rebuild
capacitor.config.ts:6:3 - error TS2322: Type '{ appId: string; appName: string; bundledWebRuntime: false; npmClient: string; webDir: string; }' is not assignable to type 'CapacitorConfig'.
Object literal may only specify known properties, and 'npmClient' does not exist in type 'CapacitorConfig'.
6 npmClient: "npm",
~~~~~~~~~~~~~~~~
Found 1 error.
So, I’m looking for other tutorials, but It seems that, despite the announcements, the integration with electron is not so simple and supported.
With these commands the error during the build phase is ignored and the demo app starts:
ionic start myPhotoGallery my-first-app --type=angular --capacitor
cd myPhotoGallery
npm i @capacitor-community/electron
ionic build
npx cap add @capacitor-community/electron
cd electron
npm run electron:start-live
I don’t know whether this is fully related, but I ran into similar issues when I first tried syncing my electron build on my ionic (react) app.
I did manage to create the electron folder (using ionic cap add @capacitor-community/electron instead of ionic cap add capacitor, since the latter is deprecated), but I simply couldn’t get the ionic build changes to reflect in electron without deleting and then fully re-adding it each time.
In case you’ve faced something like that, try running:
ionic build # as you would normally
ionic cap sync @capacitor-community/electron
Note: simply running ionic cap sync without specifying the platform (as I saw suggested in other threads) did not work for me.
And then your electron live app should be properly updated when you run
ionic cap open @capacitor-community/electron
(or simply npm run electron:start-live if you’re running it from the electron folder directly).