0

How to debug node.js app running with TypeScript in WebStorm?

1

1 Answer 1

2

Update tsconfig.json to add sourceMap=true property in compilerOptions

{
  "compilerOptions": {
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitReturns": true,
    "outDir": "lib",
    "target": "es6",
    "preserveConstEnums": true,
    "removeComments": false,
    "sourceMap": true,
    "inlineSources": true,
    "typeRoots": [
      "./node_modules/@types"
    ]
  },
  "exclude": [
    "node_modules",
    "lib"
  ]
}

In the Edit Run/Debug Configuration,

  1. Write following line in Node parameters field. Don't forget to mention your port number! In my case it is 3000

--inspect=3000 --require ts-node/register

  1. Mention your entry .ts file in Javascript file field. In my case it is bin/www.ts

    Edit Run/Debug Configurations

  2. Debug your newly created configuration

enter image description here

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

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.