TypeScript 断点调试配置
- 安装拓展 TypeScript Debugger
- 创建tsconfig.json
tsc --init
如果报错,请尝试安装typescript 模块
npm install typescript -g
- 创建launch.json
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "ts-node",
"type": "node",
"request": "launch",
"args": [
"${relativeFile}"
],
"runtimeArgs": [
"-r",
"ts-node/register"
],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
}
]
}
- 安装调试以来,注意只能本地安装,不要全局安装,不然路径无法识别
npm install typescript ts-node tsconfig-paths
- 设置断点,F5 调试
参考文档