Cordova browser app as Electron Desktop App



I was using nw.js to create Desktop App from cordova browser platform. I came across electron and found it different from nw.js.

I tried migrating existing cordova based (Ionic + Angular JS) browser based application to electron but i’m getting cordova plugin errors. Which was working fine using nw.js.

I am using some cordova plugins (keyboard, splash, uuid etc.) in existing ionic/cordova based Android and iOS applications. I created new platform for browse to prepare desktop application and using this browser platform for creating desktop app.

some errors are given below:

[1180:0814/115055:INFO:CONSOLE(9)] "Uncaught TypeError: Cannot read property 'Keyboard' of undefined", source: file:///Users/rajil/work/WSMobileUAT/platforms/electron/www/resources/mobile/js/appTab.js (9)
[1180:0814/115058:INFO:CONSOLE(70)] "Uncaught TypeError: Cannot read property 'hide' of undefined", source: file:///Users/rajil/work/WSMobileUAT/platforms/electron/www/desktopHome.html (70)
[1180:0814/115121:INFO:CONSOLE(77)] "Device Paused ", source: file:///Users/rajil/work/WSMobileUAT/platforms/electron/www/desktopHome.html (77)

the errors are due to plugins not found. using nw.js there were no error like this but using electron i am getting these errors. Is there any way to incorporate cordova plugins in electron also?

Can anybody help in solving this errors?


I’m no expert, but why are you assuming that whatever worked in nw.js also works on Electron?
Whatever dependencies your app needs, you will have to provide. So the error indicates it can’t find some keyboard object… where did you include/import whatever library provides that keyboard thing?


All these are cordova plugins. The dependency is maintained by cordova.js which is included in start-up file desktopHome.html

The code is trying to access cordova plugin objects and throwing type error might be due to dependency not injected. This was working fine with nw.js with same steps.


Still cordova plugins issue is pending. But I tried using plain source (not from cordova browser platform that adds cordova plugins also), that is working with electron. I can open application, login and access it. But found strange issue. I’m using d3.min.js file for chart rendering. this minified file is not working (chart is not prepared) but when i referenced d3.js file chart is prepared. Is it due to character set issue? minified js is not working but source does.


I hope it is ok that I reformatted your post a little. I find the error messages easier to read with the monospace font and syntax highlighting.

(See here for other cool formatting features.)


Are you definitely running cordova build browser and running Electron from platforms/browser/www? When building, Cordova generates a couple of JS files for Cordova specific stuff (including plugins) which don’t exist in your main project folder.



This issue is resolved. There was version issue with d3 library. Upgrading d3 library solved this issue. Issue was with electron build only. it was running fine on nw.js