Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

electron

elm

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?

like image 390
Nahiyan Avatar asked Apr 09 '21 06:04

Nahiyan


People also ask

How do you debug an Electron build app?

Debugging the main process You can start your Electron application in debug mode using the --debug flag, which will—by default—enable remote debugging on port 5858. Visual Studio Code is a free, open-source IDE available for Windows, Linux, and macOS and has been—coincidentally—built on top of Electron by Microsoft.


1 Answers

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.

like image 190
Nahiyan Avatar answered Oct 23 '22 15:10

Nahiyan