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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With