With node-integration false, how can I use dialog in the main process?



I’m new to Electron. I have an AngularJS app that I moved into Electron. Worked perfect after I told the BrowserWindow that ‘node-integration’: false.

I had to do this because the Angular app dependencies were loaded using Bower and simple script tags pointing to the js files we needed like toastr or kendo ui.

But now, we need to take advantage of the native dialog feature of Electron.

With ‘node-integration’: false, I can no loner use required(’ module ') in my render process JS so that I can use “remove” to talk to “dialog”

Is there a way to get to “remote” and “dialog” with ‘node-integration’: false?

Thank you,



Maybe you can use a preload script (which always has access to the node api).



From what I’m reading, preload works with web-view, which I’m not using.




According to the documentation it also works with BrowserWindow.


Thank you, I’ll give it a go. Having trouble finding an example.



Turns out this is SO simple, just hard to understand what the capabilities are.

This is all I had to do:

  1. modify the options passed to the BrowserWindow ctor by adding the preload

    mainWindow = new BrowserWindow({
        width: 1400,
        height: 1000,
        center: true,
        resizable: true,
        'node-integration': false,
        **preload: path.resolve(path.join(__dirname, 'preload.js')),**

This is the contents of the preload.js file

global.ELECTRON_SHELL = require('shell');

This is how I used it to open the url in an external browser.

function showUrl(url) {

Thank you very much for pointing this Electron New Bee in the right path,




@john I’m adding one more example.

If you want to access dialog in this scenario you need to change preload.js to:

global.ELECTRON_SHELL = require('shell');
var remote = require('remote');
global.ELECTRON_DIALOG = remote.require('dialog');

Then, just use ELECTRON_DIALOG in you render process js files.