How To Debug Node CLI (Interactive Prompts with Inquirer) With VS Code?

721 views Asked by At

I have a Node CLI built with Commander and Inquirer. I'm currently trying to debug the application using VS Code.

My current launch.json configuration:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch TS Node",
            "program": "${workspaceFolder}/index.js",
            "preLaunchTask": "npm: build",
            "skipFiles": ["<node_internals>/**"],
            "outFiles": ["${workspaceFolder}/dist/index.js"],
            "args": ["new", "-i"],
            "console": "integratedTerminal",
            "sourceMaps": true,
            "autoAttachChildProcesses": true
        },

    ]
}

This works in order to stop my application and allow me to put in input via the integrated terminal, however, it does not seem to actually attach the child process(?) or anything else, because looking at my debugger, the details are all blank at the point the process has halted:

debugger paused

Also, though I have several break points in the newNote function (which is what I'm calling via the args in the launch.json), they do not get tripped.

I found this VS Code resource quite helpful for getting me this far as far as debugging Node applications, but cannot seem to understand what I'm missing.

Inquirer also has this to say:

Debugging stand-alone executable subcommands

An executable subcommand is launched as a separate child process.

If you are using the node inspector for debugging executable subcommands using node --inspect et al, the inspector port is incremented by 1 for the spawned subcommand.

If you are using VSCode to debug executable subcommands you need to set the "autoAttachChildProcesses": true flag in your launch.json configuration.

Question Is there a setting / change to make to allow me to actually see the state of the application when it has paused to ask the questions within Inquirer?

0

There are 0 answers