"@electron/remote" cannot be required in the browser process. Instead require("@electron/remote/main").
See original GitHub issueHi, I am using electron 11.4.8 , operating System macos @electron/remote@1.1.0., build
electron build work in development mode perfect but with electron-builder it shows me an error which is:
Error: "@electron/remote" cannot be required in the browser process. Instead require("@electron/remote/main").
my index.js will execute in main process. index.js
const { join } = require("path");
require("@electron/remote/main").initialize(); // this will
module.exports = {
init: async () => {
return {};
},
getRendererAppLocation: async () => {
return `file://${join(__dirname, "..", "index.html")}`;
},
preload: async () => {
console.log("preload path", join(__dirname, "preload.js"));
// return join(__dirname, "preload.js"); // if i use this line the preload will not execute
return __non_webpack_require__(join(__dirname, "..", "preload.js")); // if i use this line the preload will execute but with above error.
},
};
preload.js
console.log("preload is executing");
const {dialog} = require("@electron/remote")
globalThis.dialog = dialog;
console.log("Debug dialog", globalThis.dialog);
in main process i do also require("@electron/remote/main").initialize();
can you please tell me what i do wrong ?
Issue Analytics
- State:
- Created 2 years ago
- Reactions:30
- Comments:12
Top Results From Across the Web
Electron.remote is undefined - node.js - Stack Overflow
Original answer: remote is needed only to require other modules from inside a render process. In the main process you just get your...
Read more >@electron/remote - npm
electron /remote` is an [Electron](https://electronjs.org) module that bridges JavaScript objects from the main process to the renderer ...
Read more >Breaking Changes | Electron
The remote module was deprecated in Electron 12, and will be removed in ... Another implication is that require() cannot be used in...
Read more >require('electron')报错后使用最新方法引入remote - CSDN博客
若在渲染进程中使用main process需要通过remote模块。eletron14.0以下,使用以下引入const { BrowserWindow } = require('electron').remoteeletro.
Read more >remote | Electron
With the remote module, you can invoke methods of the main process object without ... const {BrowserWindow} = require('electron').remote let win = new ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Try this:
I have a similar problem that log can not require @electron/remote/main. After deep look the bundle file, found the problem is @electron/remote module didn’t bundled into assets file, and mainProcess has no way to find it.
So, my resolution is simple, add @electron/remote to dependencies, add it to electorn-builder build config’s extraresources(copy files into dist/node_modules). then,
require("@electron/remote/main")
is working fine.I didn’t sure is really can get help, but mention it here for a looking. 😄