Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

187
Views
Cómo importar Menú en Electron 15

Necesito importar Menú para mi archivo render.js. Pero Remote no está definido o recibo algún error.

Con el siguiente código obtengo este error: Uncaught TypeError: Cannot read properties of undefined (reading 'members')

También probé algo de la Documentación de Electron usando el método .enable(webContents) , pero tampoco puedo hacerlo funcionar.

¿Cuál es la manera de hacer esto?

Índice.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, } });

renderizar.js:

 const { desktopCapturer } = require('electron'); const { Menu } = require('@electron/remote') console.log(Menu);
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Como se lee en el documento npm @electron/remote

 @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 Report

0

De hecho, arreglé esto.

Primero: debe agregar estas líneas en el archivo index.js :

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

Luego, también en el archivo index.js , dentro de la función createWindow() , debe incluir esto:

 remote.enable(mainWindow.webContents);

En el archivo render.js para importar el menú:

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

Verifique mi repositorio de GitHub donde tengo los archivos si esto no funcionó.

El archivo render.js es: https://github.com/Auax/electron-screen-recorder/blob/main/src/render.js

El archivo index.js es: https://github.com/Auax/electron-screen-recorder/blob/main/src/index.js

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!