admin管理员组

文章数量:1320397

I recently upgraded to electron v1.3 from 0.37 and get Cannot find module 'remote' in the renderer process.

Been bing through the docs and haven't been able to e up with much

here's a part of my code

RENDERER JS FILE

var remote = require('electron').remote;
const ipcRenderer = require('electron').ipcRenderer;
const session = remote.require('electron').session; //i'm trying to use the session module here
var app = remote.require('electron').app; //and here too

MAIN JS PROCESS

const {app} = require('electron')
var fs = require('fs');
const {ipcMain} = require('electron')
const {BrowserWindow} = require('electron')
const {session} = require('electron')
const {dialog} = require('electron')

I recently upgraded to electron v1.3 from 0.37 and get Cannot find module 'remote' in the renderer process.

Been bing through the docs and haven't been able to e up with much

here's a part of my code

RENDERER JS FILE

var remote = require('electron').remote;
const ipcRenderer = require('electron').ipcRenderer;
const session = remote.require('electron').session; //i'm trying to use the session module here
var app = remote.require('electron').app; //and here too

MAIN JS PROCESS

const {app} = require('electron')
var fs = require('fs');
const {ipcMain} = require('electron')
const {BrowserWindow} = require('electron')
const {session} = require('electron')
const {dialog} = require('electron')
Share Improve this question asked Sep 13, 2016 at 11:16 d.bayod.bayo 1644 silver badges14 bronze badges 1
  • can you past the stack trace error. – MaximeF Commented Sep 13, 2016 at 15:35
Add a ment  | 

2 Answers 2

Reset to default 4

Try with this code

const app = require('electron').remote.app

And in your Main process you can do this :

const {app, ipcMain, BrowserWindow, session, dialog} = require('electron')
var fs = require('fs');

On your renderer process you can invoke your variables like this:

var remote = require('electron').remote;
var session = require('electron).remote.session;  

var app = require('electron').app;
/*if the above line doesn't work try this*/
var app = require('electron').remote.app;

var ipcRenderer = require('electron').ipcRenderer;

And in your main.js can use this

const {ipcMain, dialog, session, app, BrowserWindow} = require('electron');
var fs = require('fs');

本文标签: javascriptelectron Cant find module remote in the renderer processStack Overflow