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.
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
- Create a new folder and run
npm init -y
in it - 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));
- Create a new JavaScript Debug Terminal
- Set a breakpoint on any line
- Run
node index.js
in it - See the breakpoint being hit 🎉
Official docs: https://code.visualstudio.com/docs/nodejs/nodejs-debugging#_javascript-debug-terminal