# VSCode Node.js Typescript Debugging

### Debugging ts-node

First create your `launch.json` ( [visual studio code doc](https://code.visualstudio.com/docs/typescript/typescript-debugging) )

To allow breakpoints to work, we need to enable source maps in our `launch.json` as shown below:

{% code title=".vscode/launch.json" %}

```
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Example",
      "type": "node",
      "request": "launch",
      "runtimeExecutable": "node",
      "runtimeArgs": ["--nolazy", "-r", "ts-node/register/transpile-only"],

      "args": ["${file}", "--sample-arg", "test"],

      "cwd": "${workspaceRoot}",
      "internalConsoleOptions": "openOnSessionStart",
      "skipFiles": ["<node_internals>/**", "node_modules/**"]
    }
  ]
}

```

{% endcode %}

Then get back to your file, and start the debugger.

![debugger statement should hit now](https://674717437-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MJ0DOfJceiIU5ANgHDU%2F-MW7BbqGOe3nDM_hDeBW%2F-MW7Qjnu7rgtOwyF-7em%2FScreen%20Shot%202021-03-18%20at%2011.02.03%20PM.png?alt=media\&token=c760be02-4d8c-4e48-a1fb-8505356a8a55)
