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

248
Views
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 answers
Answer question

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 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!