2

I'm trying to debug a Node.js application using TypeScript in VSCode. I want :

  • To simply hit "F5". I don't want to start nodemon or something else manually in a terminal.
  • The TypeScript files to be automatically recompiled when they are changed.
  • The application to be automatically restarted when TypeScript files are recompiled.

Here is my best try [project on GitHub].

Using this project :

  • I hit "F5" and the application starts correctly in debug mode. This is done by calling a Gulp task which uses nodemon to start the application using --debug-brk=5858.

  • If I add a breakpoint in app.ts, on the "response.end(...)" line, it works well.

  • But when I change the app.ts file, for example by modifying "Date1" for "Date2", the recompilation is done properly but the debugging session ends!!

I'm not sure what I'm missing, since in launch.json I do have an "attach" section with the "restart": true property.

Anybody has a working example of a Node.js application that can be debugged in VSCode with automatic TypeScript files recompilation and automatic application restart?

UPDATE : thanks a lot to Andre. It seems that achieving what I want is currently not possible. Here's an issue created to add the feature required to make it possible.

1 Answer 1

3

Just having a "Attach" launch config in the launch.json is not enough. You actually have to run it. From your description I got the impression that you are not running it because your 'F5' runs a gulp task instead.

What should work is the following: Run your gulp task in a terminal and then use 'F5' to launch the "Attach" launch config. It should attach to the node process initially and later reattach if it detects that nodemon has restarted node.

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

Comments

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.