Node JS + Pug + include scripts debugging?
Hi,
I got Node JS debugging for server side, Pug file watchers and configured server/client debugging (https://www.jetbrains.com/help/webstorm/node-debug-server-client.html)
Normal code hits breakpoints but scripts that are included in Pug files with set breakpoints don't break. Is this possible to work?
I tried checking the "Ensure breakpoints are detected when loading scripts" but didn't seem to help.
E.g. in index.pug you do something like below and set a breakpoint in myscript.js and it won't get hit.
script
include ../includes/myscript.js
Please sign in to leave a comment.
Debugging JavaScript in Pug files is not supported... I can't actually set JavaScript breakpoints in .pug files
I set the breakpoints in the included JS files, not in Pug (because as you say you can't set them here).
So in general, there is no way to set and hit breakpoints in included files other than manually setting them in Chrome and using Chrome debugger?
I tired adding "debugger;" lines and it didn't work either.
works fine for me. Did you create a JavaScript Debug run configuration for your server URL, or enable With JavaScript debugger in your Node.js run configuration, Browser/Live edit tab? Javascript included in your .pug templates is run in browser, so you need using appropriate configuration to debug it
Yes. And for clarity, if I include the script path in the PUG file then it works (the index.html page returns an include line), but if I include the script in a script block with include statement as per my post above it doesn't work (included code is inlined into html file returned by Node).
this way it doesn't work indeed, as debugging would require mapping the original template to resultant HTML, which is not possible unless sourcemaps are there... and pug doesn't yet support them (https://github.com/pugjs/pug/issues/941)
Ok, thanks. At least I know it's not supposed to work :-)