Skip to content
Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time


dbgr is a lightweight debugger function that pauses your script, watches the current file for any changes and only re-runs the specific code that's passed in to it. It's just like debugger but requires no IDE or browser dev-tools integrations.

If you like this project, please star it & follow me to see what other cool projects I'm working on! ❤️

🙋‍♂️ Why?

You can set breakpoints in Node.js with breakpoints or debugger statements, but it could be a hassle to set up and can slow down your script.

When you're debugging something heavy with slow startup (eg. server, headless Chrome, etc), you want to use something simple & light to debug.

🚀 Install

npm i -D dbgr

🚦 Quick Setup

import dbgr from 'dbgr'

// Some async process
(async () => {

    // ...

    await dbgr((resume) => {
        console.log('The debugger has started');

        // Write code here and hit save to
        // automatically re-run this function

        // Call resume() and save to resume the debugger

        // ↓ The eval below is necessary for this to work
    }, _ => eval(_))

🙋‍♀️ FAQ

How does it work?

Upon invoking dbgr, it detects the file path of the caller by using V8 stack trace API via callsites. It then watches the file for changes using When a change is detected, it parses the source code using acorn to extract the specific function passed into dbgr. It then passes it into the _ => eval(_) to run in the original context.

Does it work in TypeScript files?

Yes. While the AST parser acorn is designed for ES parsing, TS files can be loosely parsed via acorn-loose, and the content inside the dbgr hook has the types stripped via esbuild for it to be "safely" eval()'d by the JavaScript runtime.