Ionic 6 Capacitor, electron: Cordova is not available. Make sure to include cordova.js or run in a device/simulator

3.5k views Asked by At

I am trying to use the cordova plugin in a new ionic 6 project but I always run into errors regarding cordova. The plugin is properly installed and shows up in the plugin folder. I use Ionic 6 vue, capacitors and capacitor-community/electron to build windows native App. everything ok but get this error on run cordova plugin in simulator:

Native: tried calling Printer.print, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator

npm i @capacitor-community/electron
npx cap add @capacitor-community/electron
ionic build
ionic build @capacitor-community/electron && npx cap copy @capacitor-community/electron
npx cap open @capacitor-community/electron
2

There are 2 answers

1
jcesarmobile On BEST ANSWER

Capacitor doesn't support Cordova plugins on web nor electron, they are only supported on iOS and Android.

0
Victor On

There is an open issue for Capacitor on GitHub:

https://github.com/ionic-team/capacitor/issues/769

Unfortunately, Cordova plugin support is currently only available on Android and iOS.