Luis Crespo
Luis Crespo

Reputation: 788

Can I debug modules in node-webkit loaded via require?

node-webkit seems to support debugging in a very convenient way, as you can easily open the devtools by clicking on the toolbar.

Using that approach I can easily debug any JavaScript that is inside my HTML page, and even though I have not tested it, I assume I can also debug other scripts loaded via the traditional browser way, i.e.

<script src="blabla.js"></script>

However this being node-webkit, I want to exploit the module approach of node, so I can develop clean independent modules and load them via require directly from my index.html, e.g.:

<script>
    var myFunc = require("./myfunc");
    myFunc();
</script>

This works perfectly fine. The problem is, I can't find a way to debug the content of myfunc.js. I can open the module file in the debugger and set a breakpoint there, but it won't stop at it. I have also tried to add a debugger; statement in my module, but that also does not work. I have also tried the remote debugger via --remote-debugging-port=port, with the same results.

Do you know whether debugging modules is supported by node-webkit? If so, how? Otherwise, is there some useful workaround that I can use while still being able to make use of modules?

Upvotes: 2

Views: 1515

Answers (1)

Luis Crespo
Luis Crespo

Reputation: 788

I am afraid that this is explicitly not supported. According to node-webkit wiki, https://github.com/rogerwang/node-webkit/wiki/Debugging-with-devtools#bugs-of-developer-tools:

Node modules don't show in script sources

So I will have to stick with some workaround. Suggestions are welcome...

Upvotes: 1

Related Questions