Reputation: 3262
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?
Upvotes: 5
Views: 3710
Reputation: 31
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.
Upvotes: 3
Reputation: 165
I've had a similar issue, @lena answer didn't work for me either, but I solved the problem by adding "inlineSourceMap": true
to the compilerOptions
of my tsconfig.json.
Upvotes: 1
Reputation: 93868
What run confoguration do you use - Node.js Remote? Remote debugging with sourcemaps only works if sources are inlined (inlineSources=true
in tsconfig.json)
Upvotes: 1