AlexTorresDev / custom-electron-titlebar

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

Uncaught TypeError: Cannot read property 'Menu' of undefined #101

Closed TheClashFruit closed 4 years ago

TheClashFruit commented 4 years ago

Error:

Uncaught TypeError: Cannot read property 'Menu' of undefined
    at Object.<anonymous> (E:\desktopApps\Web M…\lib\titlebar.js:30)
    at Object.<anonymous> (E:\desktopApps\Web M…lib\titlebar.js:442)
    at Module._compile (internal/modules/cjs/loader.js:1145)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1166)
    at Module.load (internal/modules/cjs/loader.js:981)
    at Module._load (internal/modules/cjs/loader.js:881)
    at Function.Module._load (electron/js2c/asar.js:769)
    at Module.require (internal/modules/cjs/loader.js:1023)
    at require (internal/modules/cjs/helpers.js:77)
    at Object.<anonymous> (E:\desktopApps\Web M…bar\lib\index.js:17)

Code:

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

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

MyTitleBar.updateTitle('title');
Soahr commented 4 years ago

Same error here, same setup

EDIT : Found the solution Add 'enableRemoteModule = true' to webPreferences of mainWindow like

const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
        preload: path.join(__dirname, 'preload.js'),
        enableRemoteModule: true // <-- add this line
    },
    frame: false
})
AlexTorresDev commented 4 years ago

#

Same error here, same setup

EDIT : Found the solution Add 'enableRemoteModule = true' to webPreferences of mainWindow like

const mainWindow = new BrowserWindow({
    width: 800,
    height: 600,
    webPreferences: {
        preload: path.join(__dirname, 'preload.js'),
        enableRemoteModule: true // <-- add this line
    },
    frame: false
})

This is a real solution

Christilut commented 4 years ago

The remote module will be deprecated in a future release though.