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

답변 없음

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠