5

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?

1

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

What run confoguration do you use - Node.js Remote? Remote debugging with sourcemaps only works if sources are inlined (inlineSources=true in tsconfig.json)

1 Comment

I enabled inlineSources but the breakpoint in my .ts file isn't being hit.
1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.