Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I've been a Python/Elixir programmer for a long time and I make heavy use of pdb.set_trace()/IEx.pry().

Lately, I've inherited a very messy NodeJS backend and have been pulling my remaining hair out working without proper debugging tools. I've gone back to 'console.log' debugging, but it makes me feel like a caveman.

I can't believe that this whole popular ecosystem doesn't have a proper debugging REPL - can anybody point me in the right direction?



It does. `node --inspect-brk`. You can connect to it with VS Code or Chrome dev tools. The tricky part is whether there's build tooling infront of just the nodejs command, like converting typescript or something like that. But if you run `node`, then it's pretty easy.

Its debugging REPL is just the javascript console itself.


I looked into that a little bit, but I've got this TS transpiling crap to deal with as well, and I don't want to lose my live code reloading.

I guess I'll try again when I find the time. Was hoping there was some 3rd party package I could use to just drop in and set a trace. Thanks.


That should work fine in the vscode debugger, you just want to make sure that the transpiler you're using is generating sourcemaps. Generally they do by default. If you have issues, open a github issue and I'll fix it :)


You can do some solid debugging with NodeJS if you use the VSCode dev tools. Just add it as a debugging option and you can add breakpoints and step through functions.

Works pretty great, JavaScript is pretty nice to debug since everything is incapsulated inside an object for the most part.


As somebody else pointed out, —inspect or —inspect-brk is what you’re after.

In VsCode you can also use the “open JavaScript debug terminal” command: it opens a terminal in which any node command automatically starts with a debugger attached


Maybe not sufficient, but I just found out about python snoop

https://pypi.org/project/snoop/

deep tracer decorator


What I like about the Elixir repl, which I assume is similar to the Erlang repl is its ability to connect to a live process, a feature I haven't seen in the Node JS ecosystem.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: