electron/remote

ipcMain undefined...

jogibear9988 opened this issue · 6 comments

In my app wich uses electron I do this

   require('@electron/remote/main').initialize()

but it crashes in server.js
line 312

electron_1.ipcMain is undefined.

image

ckerr commented

I think this is a duplicate of #66

@ckerr why? the initialize could be called. the require does work

ckerr commented

Hmm, maybe I scanned this too quickly then. Sorry about that.

If I dont call the initalize, I get this error:

Uncaught (in promise) Error: @electron/remote is disabled for this WebContents. Call require("@electron/remote/main").enable(webContents) to enable it.
	at IpcMainImpl.<anonymous> (D:\mcc-client-app\resources\app\node_modules\@electron\remote\dist\src\main\server.js:317:61)
	at IpcMainImpl.emit (node:events:394:28)
	at Object.<anonymous> (node:electron/js2c/browser_init:165:10589)
	at Object.emit (node:events:394:28)

but in my index.js I do this:

win = new BrowserWindow({
    width: 1400, height: 1024, frame: false, webPreferences: {
        nodeIntegration: true,
        contextIsolation: false,
        enableRemoteModule: true,
        devTools: true
    }
})

I don't know how to do this:

   require("@electron/remote/main").enable(webContents)

cause I have no object

   webContents

fixed it,
need to add

  require('@electron/remote/main').enable(win.webContents);

in my main.js