I have a TypeScript Node.js Restify app running inside Docker container. I can connect the WebStorm Node.js Remote Debugger, but I can only debug the compiled JS files and not the TS files.
In the tsconfig.json
I have "sourceMap": true
set.
Is there anything I am missing?
WebStorm configuration In Languages & Frameworks select TypeScript, Select the option Enable TypeScript Compiler, In Command Line Options: type –module commonjs, And set the value dev (or js or whatever you like) for the Use output path: so we don't mix TypeScript and JavaScript files.
With WebStorm, you can run and debug client-side TypeScript code and TypeScript code running in Node. js. Learn more from Running and debugging TypeScript.
Hold Ctrl+Shift and click this URL link. WebStorm starts a debugging session with an automatically generated Angular Application configuration of the type JavaScript Debug.
I have found a solution using ts-node there are a few steps that you should do for doing it.
First, you must add "esModuleInterop": true
and "sourceMap": true
to your tsconfig.json
tsconfig.json
{
"compilerOptions": {
"module": "commonjs",
"esModuleInterop": true,
"target": "es6",
"moduleResolution": "node",
"sourceMap": true,
"outDir": "dist"
},
"lib": ["es2015"]
}
After that, you should install the ts-node package.
npm i -D ts-node
The last step is adding to edit the Run/Debug Configurations of the WebStorm.
Go to Run/Debug Configurations window.
Add new Node.js configuration using the +
.
Change the Node parameters
to --require ts-node/register
Then, change the Javascript file to your Typescript file, for me it is: src/app.ts
Press the OK button.
Run this configuration as dubug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With