Skip to content Skip to sidebar Skip to footer

Debugging Nodewebkit With Webstorm

I am trying to open a NW in a Webstorm so I can start debugging. When I have erro r in the App, NW windows just closes without any hint why that happened. I have found this article

Solution 1:

you didn't post any of your code, but you probably get an exception that makes the app crash immediately.

From past experience the most common exception is caused due to incorrect call to window:

window: defined as a property of 'global', points to the DOM window global object. Note that it would be updated upon page navigation. This symbol is not available at the time the script is loaded, because the script is executed before the DOM window load (source)

So if you use 'node-main' and in there you use 'window' your app will crash on startup. Look for any call to window in app.js and try to comment it. if it works - you need to put the code in functions and call them from index.html.

if this is not the case, you need to debug your code to find why it breaks. try omitting code blocks to find the bug. you can post your code for more help.

Solution 2:

Have you set up the debug configuration in Webstorm? It is separate from the normal mode.

If you need to see console messages in Windows, use Git Bash

Solution 3:

Finally found a reason why my NW window was closing sometimes. This is my setup:

package.json:

"main":"index.html","node-main":"appnw.js",

index.html:

<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>My App</title></head><body><scripttype="text/javascript">setTimeout (function () {
    window.location = 'http://localhost:9000';
},1000)

Problem was in fact that sometimes Express.js server did not start while NW was trying to "get" it. I simply used setTimout to slow it down:

setTimeout ( function () {
      app.listen(app.get('port'), function () {          
   });
  }, 2000);

Post a Comment for "Debugging Nodewebkit With Webstorm"