简体   繁体   English

如何调试WebStorm中以TypeScript运行的node.js应用程序?

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

如何调试WebStorm中以TypeScript运行的node.js应用程序?

Update tsconfig.json to add sourceMap=true property in compilerOptions 更新tsconfig.json添加sourceMap=true财产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 在我的情况下是3000

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

  1. Mention your entry .ts file in Javascript file field. Javascript文件字段中提及您的条目.ts文件。 In my case it is bin/www.ts 在我的情况下是bin / www.ts

    编辑运行/调试配置

  2. Debug your newly created configuration 调试新创建的配置

在此处输入图片说明

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

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