Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ipcMain undefined... #89

Closed
jogibear9988 opened this issue Oct 19, 2021 · 6 comments
Closed

ipcMain undefined... #89

jogibear9988 opened this issue Oct 19, 2021 · 6 comments

Comments

@jogibear9988
Copy link

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 ckerr added the duplicate This issue or pull request already exists label Oct 19, 2021
@ckerr
Copy link
Member

ckerr commented Oct 19, 2021

I think this is a duplicate of #66

@ckerr ckerr closed this as completed Oct 19, 2021
@jogibear9988
Copy link
Author

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

@ckerr
Copy link
Member

ckerr commented Oct 19, 2021

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

@ckerr ckerr reopened this Oct 19, 2021
@ckerr ckerr removed the duplicate This issue or pull request already exists label Oct 19, 2021
@jogibear9988
Copy link
Author

jogibear9988 commented Oct 19, 2021

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
    }
})

@jogibear9988
Copy link
Author

I don't know how to do this:

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

cause I have no object

   webContents

@jogibear9988
Copy link
Author

fixed it,
need to add

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

in my main.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants