Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I configure JetBrains products to debug CDK TypeScript applications that require a context value to be set?

I have a CDK application where I am getting context values, like:

const stage: StageType = app.node.tryGetContext('stage');

I followed the JetBrains documentation for setting a run configuration using ts-node, however context is created by the CDK CLI. My code fails to run with the necessary context values.

Is there a way to debug, using using the CDK CLI to start the application?

like image 468
Richard Collette Avatar asked Oct 26 '25 07:10

Richard Collette


1 Answers

I've had the same issue recently and just discovered a way to debug the CDK command via WebStorm.

Rather than debugging via node debug via npm. In my package.json I have a script of cdk that simply runs cdk (I think this is standard with the CDK?).

Then for the WebStorm configuration, use the run command, and the cdk script. In arguments you can now pass synth -- -c stage='myStageContext'

enter image description here

like image 144
Tyler Hartwig Avatar answered Oct 28 '25 21:10

Tyler Hartwig



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!