electron/remote

New @remote in Electron. How to use?

XhonorSkillline opened this issue · 2 comments

Learning to pick Electron. I started to make the function and it turned out that the remote function will disappear with the new version. But a new one has appeared. I have problems with her now. I simply cannot open the test window. Nothing happens at startup. What am I doing wrong? P.S. I touch Electron for a couple of hours, do not judge strictly. I could not find information on the Internet -_-

main.js

require('@electron/remote/main').initialize();
renderer.js

const { BrowserWindow } = require('@electron/remote');
const win = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
        enableRemoteModule: false,
        preload: path.join(__dirname, 'preload.js')
    }
});
win.loadURL('https://github.com');
win.show();

I'm closing this issue as it does not represent a bug or feature request for the remote module.

If that require statement is the entirety of your main.js, then you are missing a lot of needed setup. The renderer.js code won't be getting called at all if that's the case. Perhaps electron-quick-start would be a good place to start.

I am trying to use this in a Vue app using vue-cli-plugin-electron-builder@2.0.0-rc.6. I would welcome a small example, because I can only ever get my app to work in electron:serve, but not in electron:build. At least an example for

you'll need to configure your bundler appropriately to package the code of @electron/remote in the preload script.

would be nice, because I can't ascertain what that entails. Whatever I try, I keep running into

Uncaught Error: Cannot find module '@electron/remote'

in my renderer process. No amount of googling or digging through issues has brought any clues so far.