Dead simple debugging with VSCode JavaScript Debug Terminal

It’s 2023, and debugging Node.js (and JS in general) has never been easier. There’s really no excuse to not do it nowadays, especially with VSCode’s JavaScript Debug Terminal.

All you have to do is open a new terminal of type “JavaScript Debug Terminal”, and run your Node.js app.

VSCode terminal with JavaScript Debug Terminal option highlighted

You don’t even have to start it up with --inspect or --inspect-brk, it just works. 🎉 Simply set breakpoints in your code, and they’ll be hit as you’d expect.

Test it out yourself

  1. Create a new folder and run npm init -y in it
  2. Create a index.js file with the following content:
const add = (a, b) => {
  console.log("Adding", a, b);
  return a + b;
};

console.log(add(1, 2));
  1. Create a new JavaScript Debug Terminal
  2. Set a breakpoint on any line
  3. Run node index.js in it
  4. See the breakpoint being hit 🎉

Official docs: https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_javascript-debug-terminal


See Also