Debugging - Nx to automatically setup debugging configuration in vsCode on newly generated application

See original GitHub issue

Description

Debugging is a natural part of any development lifecycle, for both distributed, and/or mono repos, alike. Nx users may benefit tremendously should the app-level generators automatically insert the relevant debugging information into the .vscode/{tasks,launch}.json files.

Motivation

Creating an Angular, or a NestJS, or any other app is very easy within the Nx workspace, which is meant to streamline and speed up the development process. That is all good till there is a need to attach to an application and step through some complex code, and that is all to avoid excessive use of console.log(s).

At that point, one can assume, setting up the debugging information turns into a monumental task. This is true since Nx moves things around to accommodates all variety of apps so they co-exist.

The same, let’s say Angular app in Nx will give users a very hard time, should they try to set up the debugging information. However, if that application was created through NgCli, the setup would be a simple copy & paste of some configuration, right from the vsCode website.

Suggested Implementation

It would be great to automatically populate the .vscode/launch.json as well as .vcode/tasks.json with the necessary information regarding a newly generated application. Nx console already runs in & supports vsCode and the .vscode directory already exists, so we just need to add those two files.

One recommendation would be to add both launch <app> and attach <app>, so users can either have the launcher to start the app, then attach to it, or simply attached to an already laughed application.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
jonathan-barnercommented, Sep 8, 2022

I got debugging working with my node.js service as well, using this launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Debug myservice",
            "cwd": "${workspaceFolder}",
            "runtimeExecutable": "nx",
            "runtimeArgs": [
                "serve",
                "myservice",
                "--inspect"
            ],
            "skipFiles": [
                "<node_internals>/**",
                "${workspaceFolder}/node_modules/*"
            ],
            "outFiles": [
                "${workspaceFolder}/dist/**/*.js"
            ]
        }
        // repeat for each debuggable app
    ]
}
3reactions
ciriousjokercommented, Oct 6, 2021

In the meantime, does anyone have a working launch.json file for Angular where breakpoints are hit and chrome opens properly after nx serve is done?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Debugging Nx in VS Code
In this article we will show how to set up debugging for both Nx Node applications and Nx Jest libs in VS Code....
Read more >
Debugging in Visual Studio Code
To run or debug a simple app in VS Code, select Run and Debug on the Debug start view or press F5 and...
Read more >
Configure launch.json for C/C++ debugging in Visual Studio ...
Configure C/C++ debugging. A launch.json file is used to configure the debugger in Visual Studio Code. Visual Studio Code generates a launch.json (under...
Read more >
Debug Node.js Apps using Visual Studio Code
js processes that have been launched from VS Code's Integrated Terminal. To enable the feature, either use the Toggle Auto Attach command from...
Read more >
Running and debugging Node.js | WebStorm Documentation
Debugging a Node.js application · Set the breakpoints in the code where necessary. · Create a Node. · Select the newly created Node....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found