I need help, I am doing and learning about Electron and when I want to use 'remote' in my app.js throws me the following error:
TypeError: Cannot read property 'require' of undefined
This is my app.js
const { ipcRenderer, remote } = require('electron');
const main = remote.require('../main'); //The error is generated here
The location of the main.js is correct.
This is my main.js
const{BrowserWindow} = require('electron')
function hello(){
console.log('Desde Main')
}
let window
function createWindow() {
window = new BrowserWindow({
width: 799,
height: 599,
webPreferences: {
nodeIntegration: true,
contextIsolation: false,
}
})
window.loadFile('src/ui/index.html')
//window.removeMenu()//
}
module.exports = {
createWindow,
hello
}
If you need any more information do not hesitate to consult me, thank you very much.
UPDATE
I performed the indications shown in response (Electron.remote is undefined), but I throw the following error...
(electron) The remote module is deprecated. Use
https://github.com/electron/remote instead.
log @ electron/js2c/renderer_init.js:13
And then the next
Uncaught Error: Cannot find module '../main.js'
Require stack:
- C:\Users\claur\Documents\ThomasLaurence\workspace\Metales_del_Sur_ODT\src\index.js
- C:\Users\claur\Documents\ThomasLaurence\workspace\Metales_del_Sur_ODT\node_modules\electron\dist\resources\default_app.asar\main.js
-
at Module._resolveFilename (internal/modules/cjs/loader.js:887)
at Function.n._resolveFilename (electron/js2c/browser_init.js:257)
at Module._load (internal/modules/cjs/loader.js:732)
at Function.f._load (electron/js2c/asar_bundle.js:5)
at Module.require (internal/modules/cjs/loader.js:959)
at electron/js2c/browser_init.js:221
at IpcMainImpl.<anonymous> (electron/js2c/browser_init.js:221)
at IpcMainImpl.emit (events.js:315)
at Object.<anonymous> (electron/js2c/browser_init.js:161)
at Object.emit (events.js:315)
Everything I can visualize from the console in my application window