Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

253
Visualizações
Electron 14: TypeError: Cannot read properties of undefined (reading 'on')

As the title says, I am getting this error again and again whenever I am trying to change the browserwindow: TypeError: Cannot read properties of undefined (reading 'on')

According to my previous question, I had a problem with the import/export. Now that I found about ipcRenderer, I used it but still got an error:

Here is my main.js (index.js)

const { app, BrowserWindow, ipcRenderer } = require("electron")

var mainWindow = null

app.on("ready", () => {
    mainWindow = new BrowserWindow({
        "width": 500,
        "height": 500,
        "webPreferences": {
            "contextIsolation": false,
            "nodeIntegration": true,
        },
        "opacity": 0.7,
    })

    mainWindow.loadFile("src/html/welcome.html")
})

ipcRenderer.on("update", (event, args) => {
    mainWindow.loadFile("src/html/update.html")
})

And let's say this is my any js file:

const { ipcRenderer } = require("electron")

ipcRenderer.send("update")

After running the above code, I get an error. Now I comment out the ipcRenderer.on() line, the app works as expected.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If I'm not mistaken in your index.js file where you create the window you must declare ipcMain instead of ipcRenderer so here ipcRenderer.on("update", (event, args) => { mainWindow.loadFile("src/html/ update.html") }) you must change ipcRenderer to ipcMain

almost 4 years ago · Victor Samuel Franco Alvarez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda