max-mapper / max-mapper/menubar
Cannot integrate node in the menubar BrowserWindow
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 6.8k
- Forks
- 363
- PR merge metrics
- No merged PRs in 30d
Description
Error

Actual Behaviour
Uncaught ReferenceError: require is not defined
Specifications
- Menubar version: menubar v9.1.0
- Platform: windows 10
- Electron version: electron v16.0.2
Source Code
Main process
`
const MenuBar = require( "menubar" ).menubar;
let browserWindow = null;
const menubar = MenuBar( {
index: file://${__dirname}/index.html,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
} );
menubar.on( "ready", () => {
console.log( "Application is ready" );
} );
menubar.on( "after-create-window", () => {
menubar.window.webContents.openDevTools();
} );
`
Renderer process
console.log( "in renderer" );
const { clipboard } = require( "electron" );
const clippingsList = document.getElementById( "clippings-list" );
const copyFromClipboardButton = document.getElementById( "copy-from-clipboard" );
clippingsList.addEventListener( "click", event => {
const hasClass = className => {
event.target.classList.contains( className );
const clippingListItem = getButtonParent( event );
if ( hasClass( "remove-clipping" ) ) removeClipping( clippingListItem );
if ( hasClass( "copy-clipping" ) ) writeToClipboard( getClippingText( clippingListItem ) );
if ( hasClass( "publish-clipping" ) ) console.log( "Publish clipping", getClippingText() );
}
} );
const addClippingToList = () => {
const clippingText = clipboard.readText();
const clippingElement = createClippingElement( clippingText );
clippingsList.prepend( clippingElement );
};
const getButtonParent = ( target ) => {
return target.parentNode.parentNode;
};
const getClippingText = ( clippingListItem ) => {
return clippingListItem.querySelector( ".clipping-text" ).innerText;
};
const removeClipping = target => {
target.remove();
};
const writeToClipboard = ( clippingText ) => {
clipboard.writeText( clippingText );
};
const createClippingElement = ( clippingText ) => {
const clippingElement = document.createElement( "article" );
clippingElement.classList.add( "clippings-list-item" );
clippingElement.innerHTML =
<div class='clipping-text' disabled='true'></div>
<div class="clipping-controls">
<button class="copy-clipping">→ Clipboard</button>
<button class="publish-clipping">Publish</button>
<button class="remove-clipping">Remove</button>
</div>
;
clippingElement.querySelector( ".clipping-text" ).innerText = clippingText;
return clippingElement;
}
copyFromClipboardButton.addEventListener( "click", addClippingToList );
##Anyone who can help please?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the renderer error with menubar v9.1.0 on Electron v16.0.2 using the provided main- and renderer-process snippets. Inspect how the menubar BrowserWindow applies webPreferences, then verify the renderer can access its declared Electron dependency without the ReferenceError. Done means the sample menubar window loads and the clipboard interaction works.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- electron, javascript
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100