Skip to main content
blog.philz.dev

decoder ring for debugging in Node, Python, Java

(Updated October, 2024.)

Python #

As of Python 3.7:

breakpoint()

In older versions of Python (going back to at least 2.4):

import pdb
pdb.set_trace()

NodeJS #

require('inspector').open(9229, 'localhost', true);
debugger;

But if you're in a module context:

import('inspector').then((inspector) => {
	if (inspector.url() === undefined) {
		inspector.open(9229, 'localhost');
		inspector.waitForDebugger(); // optional
	}
	debugger; // sets a breakpoint; optional
});

To attach, use chrome://inspect/, use IntelliJ, or the following launch.json in VSCode:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach to Process",
      "port": 9229,
      "skipFiles": [
        "<node_internals>/**"
      ],
      "restart": true
    }
  ]
}

Java / JVM #

And somewhat to Java's

java "-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=4242"