Search code examples
electronelm

Is It Possible to Use the Elm's Debugger in an Electron App During Development?


I'm using Elm 0.19.1 to build the interface of a desktop app, which in turn is based on Electron.

However, in debug mode of Elm, I can't open the debugger. This is what shows up in the console of the app's window: Uncaught TypeError: Cannot set property 'title' of undefined.

It's triggered by this piece of Elm's generated JavaScript code:

var doc = debuggerWindow.document;
doc.title = 'Elm Debugger';

Apparently, the debugger window object doesn't have a document property inside it, possibly due to the fact that each window in an Electron app runs on its own process. Is there any way to fix this and get Elm's debugger up and running during the development of my app?


Solution

  • It's possible to fix this issue by setting webPreferences.nativeWindowOpen to true in the options of BrowserWindow. The options are documented here in official Electron's documentation. This should fix the issue by letting us use Window.document as we do in the browser. This answer is totally based on bruchmann's solution in Elm's discourse.