Debug Node.js CLIs with the VS Code Debugger and the `Debug` module

InstructorShawn Wang

Share this video with your friends

Send Tweet

You're going to run into a lot of frustration writing Node CLI's unless you get good at debugging. (Even if you use TypeScript!) To understand code execution (particularly code you didn't write), you should be comfortable using the VS Code Debugger for its excellent step-through and watch features. But in case you don't know where the problem is (particularly for heavily nested codebases like React) or if you're looking for performance issues rather than code errors, you'll also want a robust logging solution. The debug module is best in class and is built into Oclif.

Ron
~ 5 years ago

Good cover for the debugging, thanks for sharing. One suggestion, I think it worth to mention: to make the debug work, we need to turn on debug.node.auto.Attach toggle in settings.

Siafu
~ 3 years ago

I have no idea how to get this working in the shell using DEBUG=* yarn mycli. I have tried bash, zsh and fish shell to no avail. I asumption is that I need to replace mycli part with my bin command. My shell thinks i'm trying to run a yarn script hense the error message "error Command "mycli" not found" Please help.

Siafu
~ 3 years ago

I got it wokring, needed to setup a yarn workspace.