1

I'm trying to create a CLI tool using TypeScript, and using WebStorm as my IDE. Try as I might, I cannot seem to get the debugging function to work. I started my Node.js adventures in CLI programming based on this tutorial. I am able to transpile the TS source by running npx tsc, and I'm able to run the resulting JS file from the CLI. I'm also able to run it from a Run Configuration in WebStorm. What I can't do is debug. I've tried setting breakpoints and running it as a Debug configuration. I've tried running it with the --inspect-brk option and a separate "Attach to Node.js/Chrome" configuration (all network addresses and ports look kosher). I've gotten it to say "Debugger attached." But it just never stops at any breakpoints in the IDE. What am I missing here?

1 Answer 1

2

You need to make sure to enable sourcemaps generation when compiling Typescript to JavaScript to be able to debug your code. To get them created, add "sourceMap": true to your tsconfig.json

See https://www.jetbrains.com/help/webstorm/running-and-debugging-typescript.html for more info

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

1 Comment

Thanks! I am accepting your answer, although I confess that the minute I got past this I ran into the fact that I don't have a bundler for this, so everything like import/requires of images failed. :facepalm: Oh well. Thanks again! One step closer...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.