0

I have Nodejs typescript project

I am debugging my (Jest) tests with VS Code

I receive an error with a stack trace:

at OAuth2Client.request (node_modules/@badgateway/oauth2-client/src/client.ts:288:22)

I used Cmd+click to open the file node_modules/@badgateway/oauth2-client/src/client.ts in the editor and set a breakpoint.

When I run the test again under debugger it does not stop at the breakpoint.

I am 99.9% certain this line of code is reached and is executed, so I believe the problem is likely to do with it being a 3rd party Typescript file, in my node_modules (breakpoints in .ts files of my project itself work fine).

I have a tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "target": "es2020",
    "esModuleInterop": false,
    "strict": true,
    "outDir": "build",
    "sourceMap": true
  },
  "include": ["src/**/*", "jest.config.js", "jest.setup.ts"]
}

Node 16
VS Code 1.74.3

Anentropic
  • 32,188
  • 12
  • 99
  • 147
  • The first thought that came to mind is the justmycode flag with launch.json, however I am not familiar with TS or tsconfig.json. Does this SO [post](https://stackoverflow.com/questions/31169259/how-to-debug-typescript-files-in-visual-studio-code) help by any chance? – kyrlon Jan 31 '23 at 14:49
  • `justMyFlag` didn't seem to do anything (and was linted as an invalid property). What did work was to break in my own code and then step through gradually until I got the the target lib file... this was the compiled `client.js` instead of the original `client.ts` from the lib. With the .js file open in the editor I was able to put a working breakpoint in there – Anentropic Jan 31 '23 at 16:12

0 Answers0