Nx should help provide some debug configs or a guide for VSCode #23270
Replies: 5 comments 1 reply
-
To add to this, i'm not even sure you can debug a nestjs app. when i serve my app, it gets built in production mode...
|
Beta Was this translation helpful? Give feedback.
-
I've converted this to a discussion to continue discussing what kind of particular configs people would like to see added. |
Beta Was this translation helpful? Give feedback.
-
To debug in VS Code, you can open a JavaScript Debug Terminal and start the NestJS App. This works for me with this old
For some reason, the newer version breaks debugging in VS Code. I am interested, however, in debugging a Dockerized set of Microservices - from launch (meaning, I would want to add breakpoints in the bootstrap process and not have to first launch the app with
Then you would start the services with docker compose up, then start each debugging service. Although this is not ideal, this set up did NOT work for me. Here's a sample docker-compose.yml
The most convenient would be to pass a flag when serving the service and debugging should work whether in Docker or local machine. |
Beta Was this translation helpful? Give feedback.
-
I posted an SO question about debugging an Nx mono-repo with multiple NestJS apps running in Docker. I also pushed a repo with Dockerfile, docker-compose.yml, and VS Code launch: Running the app in VS Code within a JavaScript Debug Terminal does hit breakpoints, but I have not been able to get it to debug when running in Docker. This is problematic because the alternative is to start up each service manually in it's own terminal. |
Beta Was this translation helpful? Give feedback.
-
Description
Nx should provide some debug configs for VSCode. More specifically, when we have apps in this monorepo like NestJS, Nx should provide us a launch.json file that would set up the debugger in VSCode such that we can easily attach to our app and be able to debug it step-by-step, without getting any issues with breakpoint bindings.
Motivation
I tried to debug my NestJS app in my Nx monorepo. I searched online to find the right launch.json config needed for my setup. Some provided a config that would launch the app, while others provided a config that would attach to an existing process, which is what I want.
However, when I try to run the debugger with my script, it worked. But when I try to set the breakpoints, it says it won't bind. I am using the default Nx setup with NestJS. Some people online are suggesting that the issue may be with the source maps. Again I'm not sure.
I am using a setup that involves all my apps being defined in the apps/ directory, and they would bootstrap source code from all my libraries defined in my libs/ directory, that exists at the same level as apps/.
Furthermore, when I try to set this up to debug the app on a Docker container, and have that container expose the debug port, I get issues where I can't connect to it.
Answers online are not very clear here in this regard, and it's taking me hours to try to find some solution. I asked on Discord, but I'm not getting any answers there.
I want to use Nx as my monorepo framework, but I don't want to lose debug capabilities.
Suggested Implementation
A video or a written guide that explains how to go about debugging apps (including NestJS) in an Nx monorepo in VSCode.
Maybe have Nx create the launch.json for us. Granted, this would be specific to VSCode.
Beta Was this translation helpful? Give feedback.
All reactions