Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
How to import Menu in Electron 15

I need to import Menu for my render.js file. But either Remote is undefined or I get some error.

With the following code I get this error: Uncaught TypeError: Cannot read properties of undefined (reading 'members')

I also tried something from the Electron Documentation using the .enable(webContents) method, but I cannot get it working either.

What's the way of doing this?

Index.js:

const { app, BrowserWindow } = require('electron');
const path = require('path');

// Handle creating/removing shortcuts on Windows when installing/uninstalling.
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
  app.quit();
}

const createWindow = () => {
  // Create the browser window.
  const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
      nodeIntegration: true,
      contextIsolation: false,
    }
  });

render.js:

const { desktopCapturer } = require('electron');
const { Menu } = require('@electron/remote')
console.log(Menu);
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

As read in the npm @electron/remote doc

@electron/remote/main must be initialized in the main process before it can be used from the renderer:

// in the main process:
require('@electron/remote/main').initialize()
about 4 years ago · Juan Pablo Isaza Denunciar

0

I actually fixed this.

First: You need to add these lines in the index.js file:

const remote = require('@electron/remote/main');
remote.initialize()

Then, also in the index.js file, inside the createWindow() function you need to include this:

remote.enable(mainWindow.webContents);

In the render.js file to import menu:

const remote = require('@electron/remote')
const { Menu } = remote;

Check my GitHub repo where I have the files if this didn't work.

The render.js file is: https://github.com/Auax/electron-screen-recorder/blob/main/src/render.js

The index.js file is: https://github.com/Auax/electron-screen-recorder/blob/main/src/index.js

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda