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

时间:2019-01-21 14:11:06

标签: node.js typescript debugging webstorm

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

1 个答案:

答案 0 :(得分:1)

更新 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"
  ]
}

编辑运行/调试配置中,

  1. 节点参数字段中写以下行。不要忘记提及您的端口号!在我的情况下是 3000

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

  1. Javascript文件字段中提及您的条目 .ts 文件。在我的情况下是 bin / www.ts

    Edit Run/Debug Configurations

  2. 调试新创建的配置

enter image description here

相关问题