简体   繁体   English

如何在Intellij IDEA中调试打字稿

[英]How to debug typescript in Intellij IDEA

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. 我正在用猫鼬数据库在打字稿中编写订单应用程序的后端。我正在使用'intellij-IDEA'IDE进行开发。 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. 项目使用gulp任务运行器运行。我正在用邮递员测试我的api。在某些情况下,我无法跟踪项目中的代码流。 I have tried printing with 'console.log()'. 我尝试使用'console.log()'打印。 But, it has limits. 但是,它有局限性。 So, help me to debug typescript as it doesn't involve any browser activity. 因此,请帮助我调试打字机,因为它不涉及任何浏览器活动。

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. 当使用nodemon作为节点解释器并将ts-node用作嵌入式编译器时,我能够使IntelliJ调试Node Typescript应用程序。 No need to pre-compile the code, ts-node does it real-time in memory. 无需预编译代码, ts-node可以在内存中实时进行编译。

// 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! 然后在Debug模式下运行Node.JS运行配置,并命中断点!

If using Linux, change the node interpreter to ./node_modules/bin/nodemon (without .cmd) 如果使用Linux,请将节点解释器更改为./node_modules/bin/nodemon (不带.cmd)

You can use node-instpector , it does a good job helping debug NodeJS apps. 您可以使用node-instpector ,它可以很好地帮助调试NodeJS应用程序。 Here's a good tutorial . 这是一个很好的教程

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM