0

am trying to learn typescript and looking for some help with setting up debugger support in VS code. Here is my sample TS app which is a standalone app just prints "Hello World" text in console on data entered in console. How do i provide console input after the application is launched? I place a break point in console.log at line 6, the execution stops there when launched. But I want to enter runtime console input and inspect the console.log at line 4.

Index.ts:

class Startup {
    public static main(): number {
        process.stdin.on("data",(buffer) => {
            console.log("Hello World);
        });
        console.log("Test breakpoint");
        return 0;
    }
}
Startup.main();

Launch.json {

"version": "0.2.0",
"configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "skipFiles": [
            "<node_internals>/**"
        ],
        "preLaunchTask": "tsc: build - src/tsconfig.json",
        "program": "${workspaceFolder}/src/index.ts",
        "outFiles": ["${workspaceFolder}/dist/**/*.js"]
    }
]

}

1 Answer 1

2

The vscode's Debug Console doesn't support input, so you need a different terminal that does, the integrated one would do just fine. In order to move debug execution from the Debug Console to Terminal just add a setting to your launch.json:

{
    ...
    "console": "integratedTerminal"
    ...
}

and run debugger again. This way you'll be able to input to command line prompts.

Sign up to request clarification or add additional context in comments.

2 Comments

yeah it worked. thank you. with this configuration, now vs code debugger will use the default system terminal?
The one configured as default in vscode (usually it's the system default, but can be changed).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.