How to set up application menu in electron?
<p>if i start the <a href="https://github.com/atom/electron-quick-start" rel="noreferrer">electron-quick-start</a> application, i get a full OSX menu:</p>

<p><a href="https://i.stack.imgur.com/DMHr3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DMHr3.png" alt="enter image description here"></a></p>

<p>I then add this code, mostly copied from docs, to my main.js:</p>

<pre><code>const Menu = require('menu');                                                                                                                                                                            
const MenuItem = require('menu-item');
var mainmenu = new Menu();
mainmenu.append(new MenuItem({ label: 'MenuItem1', click: function() { console.log('item 1 clicked'); } }));
Menu.setApplicationMenu(mainmenu);
</code></pre>

<p>I also tried to use menu template code from the <a href="https://github.com/atom/electron/blob/30d815e28f0bf0215da9e5a0e85de280a86b5cc9/docs/api/menu.md" rel="noreferrer">electron menu docs</a>, with the exact same disappointing result:</p>

<p><a href="https://i.stack.imgur.com/hEBM4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/hEBM4.png" alt="enter image description here"></a></p>

<p>I also tried to add the code above to index.html, literally copying the code on Menu's doc. Same thing.</p>

<p>Any idea what is wrong?</p>