question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read properties of undefined (reading 'members')

See original GitHub issue

So I’m new to electron, but not to NPM and certainly not to JavaScript. Initially when I was getting errors they were things like “require” is not defined. I read through the issues and updated this like so:

main.js

const createWindow = () => {
    const win = new BrowserWindow({
        width: 800,
        height: 600,
        titleBarStyle: "hidden",
        webPreferences: {
            preload: path.join(__dirname, 'preload.js'),
            enableRemoteModule: true // <-- as you can see I do have this already.
        },
    })

    ipcMain.handle('dark-mode:toggle', () => {
        if (nativeTheme.shouldUseDarkColors) {
          nativeTheme.themeSource = 'light'
        } else {
          nativeTheme.themeSource = 'dark'
        }
        return nativeTheme.shouldUseDarkColors
    })

    ipcMain.handle('dark-mode:system', () => {
        nativeTheme.themeSource = 'system'
    })

    win.loadFile('index.html')
}

I have the code in my preload script, after I removed it from my render script where it also wasn’t working. Here is the important sections of my preload.js

const customTitlebar = require('custom-electron-titlebar');

window.addEventListener('DOMContentLoaded', () => {

    let MyTitleBar = new customTitlebar.Titlebar({
        backgroundColor: customTitlebar.Color.fromHex('#ffffff')
    });

    const replaceText = (selector, text) => {
        const element = document.getElementById(selector)
        if (element) element.innerText = text
    }
      for (const dependency of ['chrome', 'node', 'electron']) {
        replaceText(`${dependency}-version`, process.versions[dependency])
    }
})

The actual behavior is as follows:

  1. I use npm run start
  2. The app opens, completely white, then loads content after about 20 seconds with no titlebar present.
  3. Then I open developer tools and it gives me the error that is the title for this issue with lots of things having to do with remote.js, and a lot of yellow errors like DevTools failed to load source map: Could not parse content, Unexpected end of JSON input. It always points to files with formats following “foo”.js.map

Expected behavior I would expect a titlebar and a working app

Desktop (please complete the following information):

  • OS: Windows 11 Home 21H2
  • Electron 16.0.7
  • Node Version: v14.18.1

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ShivamRawat0lcommented, Jan 24, 2022

@AlexTorresSk It is now working for me fine. Just run the code in the preload.js and every thing should work fine. I was trying to run it inside the react js without proper params.

1reaction
ShivamRawat0lcommented, Jan 22, 2022

Lol. Just getting this same error. Is it due to the version ? @mcnamara-charles

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot read properties of undefined (reading 'members')
I get this error every time: name: `${guild.members.filter(member => !member.user.bot).size} users!` ^ TypeError: Cannot read properties of ...
Read more >
Cannot read property 'members' of undefined - Glitch Support
I'm trying to kind of make a ,kill command for a discord bot. Every time I try and run it, it comes out...
Read more >
Cannot read properties of undefined (reading 'member') - Reddit
Your error is indicating that the message variable has the value undefined , and you cannot do undefined.member because undefined doesn't have a ......
Read more >
typeerror: cannot read properties of undefined ... - You.com
cannot read property 'members' of undefined means that property members of object list doesn't exist as it was never defined to JS exactly...
Read more >
Members List View JavaScript Errors - Cannot read properties ...
Specifics. angular.js:15697 TypeError: Cannot read properties of undefined (reading 'allowedActions') at ContentAppListViewController.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found