LATEST: I’m stuck again - see my reply
I went through the nodejs tutorial as far as getting it to auth with SAFE Browser (mock) - no problems.
I moved to work on a new electron app which I generated with electron-cli and tried to add the SAFE Auth code from the tutorial into that.
The problem I have is that in the tutorial use is made of electron.remote.app and electron.ipcRenderer, but this doesn’t work in my electron app (which complains they are undefined). I noticed the electron versions were different 1.8.4 in the Tutorial and 2.0.0 in my app, so I edited the package.json version to ^1.8.4
and tried again. It actually used v1.8.6 (don’t know why). Anyway it doesn’t fix the issue.
So I searched for problems with ipcRenderer. There are old reports this was due to npm having a package called electron, which was not the electron I wanted (atom.electron or something). I think, but am not sure, that this is no longer the issue, so I wonder if any of you electron experts can shed some light here.
The offending lines are:
const ipc = electron.ipcRenderer
ipc.on('system-uri-response', async (event, resAuthUri) => {
Which complains that ipc is not defined. Similarly, app is not defined when I do this:
const app = require('electron').remote.app;
which causes errors when app is used because it is undefined.
The code which I am modifying, and works until I try to add the above uses this:
const {app, BrowserWindow} = require('electron')
In this case app is defined. I’m baffled. Probably its something simple and due to the two things being created in different ways, but I don’t understand how to solve it.
UPDATE: I think the issue is indeed two things called electron, having noticed the following line and added it to my package.json I re-installed electron and I get past the above errors, but it seems that now there are other incompatibilities.
"postinstall": "npm rebuild --runtime=electron --target=1.8.4 --disturl=https://atom.io/download/atom-shell --build-from-source"
I can probably sort this now - I’m going to try strip the angular stuff out of the tutorial rather than merge it into something else.