15 Apr 2016
Why I don’t like Popular Options
There are several ways of debugging Node.js, here are few of the reasons why I don’t like the most popular ones
Builtin CLI debugger
- It doesn’t have a GUI of course
- It’s slow and even hangs at times
- You have to remember it’s commands
- Debugging complex problems is nearly impossible if not impossible
- It shows ES6 Maps and Sets as
- It shows objects as empty randomly
- It is generally slow
- It’s very unstable
- The IDEs are costy
- Each has their own UI
- They are hard to setup
- They lack advance features
Electron to the rescue
Electron is an open source project by GitHub, it is basically Chromium + Node.js. It has the best of both worlds, node’s
global s and all the other APIs along with Chromium Dev Tools.
I have written a small wrapper around Electron to allow for quick Node.js debugging. It’s called DeNode , short for Debug Node. You can install it using npm
npm install -g denode
It registers itself as
denode bin, it accepts an optional file path of the node module to execute on boot.
denode denode ./index denode `which browserify`
What’s awesome about this?
- You can click and expand on deep nested objects
- You can profile your apps for memory leaks and CPU time
- You can set breakpoints on the fly
- You can update running code from dev tools
- Basically, all the awesomeness of Chromium Dev Tools
What’s the side effect?
- Not having the ability to execute it over a network or VM, theoretically you could do X forwarding but it would get too slow and painful
That’s what I use to debug my Node.js app, let me know what you think of it in the comments below.