How to debug node.js app running with TypeScript in WebStorm?
1 Answer
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,
- 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
Mention your entry .ts file in Javascript file field. In my case it is bin/www.ts
Debug your newly created configuration

