Image shows my Project Structure.I am writing back-end for order app in typescript with mongoose database.I am using 'intellij-IDEA' IDE for development. Project run with gulp task runner.I am testing my api's with postman.In some cases, I am unable to track the flow of code from project. I have tried printing with 'console.log()'. But, it has limits. So, help me to debug typescript as it doesn't involve any browser activity.
-
Add more details. Show structure of your project in Idea. Why you did not tell about Idea, but use it in the title? What do you want to get from idea in this case? What you have tried with idea?sphinks– sphinks2016-07-22 11:42:53 +00:00Commented Jul 22, 2016 at 11:42
-
I am using 'intellij-idea' IDE for development. I want to know how to debug in that IDE. As this project doesn't require browser for running. I am testing API's with POSTMAN application. It is easy to add breakpoint & debug if it was Front-end but how to do it in the case of calling to Back-end API's.Krishna Ghatul– Krishna Ghatul2016-07-25 05:55:44 +00:00Commented Jul 25, 2016 at 5:55
-
Does this answer your question? How to debug server side TypeScript code in WebStormJoseph Horsch– Joseph Horsch2022-11-03 20:50:39 +00:00Commented Nov 3, 2022 at 20:50
Add a comment
|
2 Answers
I was able to get IntelliJ to debug Node Typescript apps while using nodemon as the node interpreter and ts-node as the inline transpiler. No need to pre-compile the code, ts-node does it real-time in memory.
// nodemon.json
{
"execMap": {
"js": "node",
"ts": "./node_modules/.bin/ts-node"
},
"watch": [
"app",
"config"
],
"ext": "js,ts"
}
Then run the Node.JS run configuration in Debug mode, and breakpoints are hit!
If using Linux, change the node interpreter to ./node_modules/bin/nodemon (without .cmd)
You can use node-instpector, it does a good job helping debug NodeJS apps. Here's a good tutorial.
