AlexTorresDev / custom-electron-titlebar

Custom electon title bar inpire on VS Code title bar
MIT License
868 stars 149 forks source link

Cannot read property 'Menu' of undefined #140

Closed spyynz closed 2 years ago

spyynz commented 3 years ago

I get an error every single time I try to use this even when I follow tutorials. I have done step-by-step tutorials, read docs, etc. and it still shows this error. What do I do??? Is this an issue with this package?

ericblade commented 3 years ago

enable the remote module?

spyynz commented 3 years ago

yes but I get the same error except instead of 'Menu' it's 'getElementByClass'

timlg07 commented 3 years ago

Is this an issue with this package?

No, it's not.

Can you share a bit of what you've tried so far?
And can you test this simple example (custom-electron-titlebar-minimal-example) and see if it works for you?

ericblade commented 3 years ago

fwiw, use with remoteModuleEnabled: false, requires some rearchitecture, probably https://github.com/AlexTorresSk/custom-electron-titlebar/issues/136

yep84 commented 3 years ago

I'm facing the same issue.

Uncaught TypeError: Cannot read property 'Menu' of undefined C:\...\node_modules\custom-electron-titlebar\lib\titlebar.js:31

Here are my webPreferences settings:

    webPreferences: {
        nodeIntegration: true,
        contextIsolation: false,
        enableRemoteModule: true,
      preload: path.join(__dirname, 'preload.js')
    }

Node.js 14.16.0 Chromium 89.0.4389.128 Electron 12.0.7

ngudbhav commented 3 years ago

yes but I get the same error except instead of 'Menu' it's 'getElementByClass'

I got it working by using

window.addEventListener('DOMContentLoaded', () => {
  new customTitleBar.Titlebar()
});