This explains how to set up debugging an Nx NestJS project from VSCode.  
It debugs a running NestJS instance in attach mode.

### 1. Create launch.json

Create a `launch.json` file from VSCode's Run and Debug > gear icon.

```json
{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "attach",
      "name": "Attach NestJS WS",
      "restart": true,
      "sourceMaps": true,
      "cwd": "${workspaceFolder}/server"
    }
  ]
}
```

> The `server` in `"cwd": "${workspaceFolder}/server"` is  
> the name (folder name) of the NestJS project created with Nx, so change it as appropriate.

### 2. Start the NestJS project

In the VSCode terminal, run the following command.

```shell
nx serve server
```

### 3. Start debugging

VSCode's Run and Debug > Start Debugging

![img](/plants/nx-nestjs-vscode-debug/1.png)
