Jack Murphy
Jack Murphy

Reputation: 3030

How do I add runtime breakpoints to a TypeScript compiled project?

Question: How do I enable breakpoints to be appended while executing when debugging a Typescript Node.js app?

Context: I currently have a server side application run through the nodevm. My modules are built using TypeScript. I'm currently using WebStorm, and its TypeScript transpiler. As TypeScript is a transpiled language, I know the final output is a .js file.

Right now my breakpoints work correctly as long as they are set when the node process starts. Coming from other languages, you can set breakpoints as you move through your code at runtime. Is it possible to do this?

Goal: Launch Process - Hit Breakpoint A -> Add Breakpoint B -> Play -> Execution stops at B.

Current: Launch Process - Hit Breakpoint A -> Add Breakpoint B -> Play -> Execution ignores breakpoint B until restart.

I'm more interested in ANY solution that enables this experience, not just WebStorm.

[names redacted] Current Debug Configuration

Upvotes: 0

Views: 535

Answers (2)

Bowden Kelly
Bowden Kelly

Reputation: 370

This works today in VS Code.

There might be some light configuration based on how your source maps are setup, but there are great docs on TS debugging in VS Code. You can also reference this node-typescript sample that is preconfigured for VS Code that I've been working on.

Upvotes: -1

chrisbajorin
chrisbajorin

Reputation: 6153

My current workaround to the webstorm issue is to use the remote debugger. Start your app up with node --debug-brk=5858 server.js and add a 'Node.js Remote Debug' configuration:

enter image description here

This will pause the application on start up until you start your remote debugger listening on port 5858. I spin up the server in a terminal window, flip over to Webstorm and start up the debugger. This will allow you to insert breakpoints without restarting either the server or debugger.

Upvotes: 0

Related Questions