2

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.

3
  • 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? Commented 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. Commented Jul 25, 2016 at 5:55
  • Does this answer your question? How to debug server side TypeScript code in WebStorm Commented Nov 3, 2022 at 20:50

2 Answers 2

3

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"
}

Run config

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)

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

3 Comments

It worked well for some time, but now it just starts my server and doesn't stop on any breakpoint
ts-node ^5.0.1 changed its settings
Didn't work for me. wind up getting node: bad option: --expose_debug_as=v8debug
0

You can use node-instpector, it does a good job helping debug NodeJS apps. Here's a good tutorial.

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.