How to debug Typescript AWS CDK code in Cloud9?

0

Can someone provide a step-by-step guide on how to effectively debug TypeScript CDK code in Cloud9?

I'm able to set breakpoints by clicking in the gutter (the space left of the line numbers), as described in the "Debug Your Code" documentation.

However, I'm having trouble getting the debugger to pause at the breakpoints when running the cdk deploy command. I've tried the following steps:

  1. Added the --inspect-brk flag to the cdk deploy command in the cdk.json file:
  "app": "npx ts-node --prefer-ts-exts --inspect-brk bin/aws-genai-llm-chatbot.ts"

However, when I run cdk deploy, I get the following error:

Error: Unknown or unexpected option: --inspect-brk

It seems like the --inspect-brk flag is not recognized by the ts-node command.

  1. As an alternative, I tried modifying the cdk.json file to use the node command directly with --inspect-brk and specifying the path to the ts-node executable:
  "app": "node --inspect-brk ./node_modules/ts-node/dist/bin.js --prefer-ts-exts bin/aws-genai-llm-chatbot.ts"
  1. Then I set breakpoints in my TypeScript CDK code by clicking on the gutter to the left of the line numbers.
  2. When I ran the cdk deploy command in the terminal, I got the following output:
Debugger listening on ws://127.0.0.1:9229/b000124e-7e73-4d3e-adb7-abf50620df8a
For help, see: https://nodejs.org/en/docs/inspector

So then I opened the debugger window, but didn't see anything in there, as you can see in the screenshot.

I did find a fantastic article on "Debugging TypeScript/JavaScript CDK projects - a few tips and tricks" but it wasn't specific to Cloud9.

Enter image description here

Nessuna risposta

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande