Electron run by Capacitor in Ionic 5: console logging and live reload not working

I’ve used Electron standalone before, and console.log() commands in main.js worked just fine (output to IDE console) and the electron-reload module also worked fine when content changes were detected in the Electron root folder.

I’ve now started a new Ionic 5 project, and added Electron to the project via Capacitor. Capacitor makes a few necessary changes to Electron (e.g. renaming main.js to index.js etc), I’ve now also have to start electron via capacitor npx cap open electron .

In doing so, console.log() commands in index.js are now NOT being output to the IDE console, errors are not being output to console, and the electron-reload module now serves a blank page when changes are detected… the only console output that I get is:

$ npx cap open electron
[info] Opening Electron project at ...

Is this a capacitor limitation or what configurations must be done to make this work ?


also updated electron to latest 9.0.4 - same result.

If you CD into the platform folder and run electron . is it behaving the same?

when I go into the /electron folder that Capacitor created within the Ionic framework and run electron ., the console logs bash: electron: command not found

can anybody help with this ?

here are steps to reproduce this:

# install ionic CLI
$ npm install -g @ionic/cli

# create project w/ capacitor
$ ionic start <project name> blank --type=angular --capacitor

# create initial build, needed by cap for electron 
$ cd <ionic_project_folder>
$ ionic build

# add electron via cap
$ npx cap add electron

# run electron
$ npx cap open electron

if you enter console.log messages in electron’s index.js, none of them will be logged…

go to the electron folder and run
electron ./

Then you have the right console. Seems npx cap open electron does not pass the logging through