TypeError: Cannot read properties of undefined (reading 'members')
See original GitHub issueIssue Description
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:
- I use
npm run start
- The app opens, completely white, then loads content after about 20 seconds with no titlebar present.
- 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:
- Created a year ago
- Comments:12 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@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.
Lol. Just getting this same error. Is it due to the version ? @mcnamara-charles