{"id":749,"hash":"622ba44aea838da8473d545e0e764c4f0fb318fafa5dbaed3d3a36158753e4dd","pattern":"Electron.remote is undefined","full_message":"I have trouble with using Electron. As you can see the title, when i load remote module, it saids it is undefined. This is the code of entry js:\n\nconst electron = require('electron');\nconst { app, BrowserWindow, Tray, remote, ipcMain } = electron;\n\nfunction initApp() { ... }\n\napp.on('ready', () => {\n    initApp();\n\n    console.log(electron);         // object, but no remote inside\n    console.log(electron.remote);  // undefined\n    console.log(remote);           // undefined\n});\n\nand i tried to follow official doc here: http://electron.atom.io/docs/api/remote/\n\nwith\n\nconst { remote } = electron;\nconst { BrowserWindow } = remote;\n\nlet win = new BrowserWindow({width: 800, height: 600});  // error! BrowserWindow is not a constructor blabla\n\n...\nremote.getCurrentWindow().focus();\n\ni don't know what am i missing. any advice will very appreciate.","ecosystem":"npm","package_name":"node.js","package_version":null,"solution":"Update 2020, since this answer still appears at the top. For the original answer to work in current versions of Electron, you need to set enableRemoteModule when creating the window in your main process.\n\nconst myWindow = new BrowserWindow({\n    webPreferences: {\n        enableRemoteModule: true\n    }\n}); \n\nOriginal answer:\n\nremote is needed only to require other modules from inside a render process. In the main process you just get your modules directly from require('electron'). Which it looks like is done in the example just with remote unnecessarily added.\n\nRender process:\n\nconst { remote } = require('electron');\nconst { BrowserWindow } = remote;\n\nMain process:\n\nconst { BrowserWindow } = require('electron');","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/37884130/electron-remote-is-undefined","votes":77,"created_at":"2026-04-19T04:51:36.206921+00:00","updated_at":"2026-04-19T04:51:36.206921+00:00"}