Daniel Stephens
Daniel Stephens

Reputation: 3209

Electron remote is always undefined

I am using Electron 10 and Node v12.6.3.

I try to open a FileDialog from the renderer process. This is not the first question on SO regarding this problem, but I can't find any solution that works for me. nodeIntegrations is enabled

  win = new BrowserWindow({
    webPreferences: {
      webSecurity: false,
      nodeIntegrationInWorker: true,
      nodeIntegration: true,
      allowRunningInsecureContent: (serve) ? true : false,
    },

I tried the following:

1) import * as electron from "electron";
2) import { remote } from "electron";
3) var remote = require("electron").remote;
...

Also executing require("electron").remote within a function return undefined. What could I miss here?

In any instance remote seems to be undefined. Can anyone help me? I am lost.

Upvotes: 0

Views: 345

Answers (1)

aabuhijleh
aabuhijleh

Reputation: 2464

According to #21408

In Electron 10.x, set the default value of enableRemoteModule to false. Apps that use remote will need to update to explicitly set enableRemoteModule to true.

Upvotes: 2

Related Questions