2024年6月

  1. 安装拓展 TypeScript Debugger
    2024-06-12T05:54:46.png
  2. 创建tsconfig.json
    tsc --init
    如果报错,请尝试安装typescript 模块
    npm install typescript -g
  3. 创建launch.json
    2024-06-12T06:00:51.png
{
    // 使用 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"
        }
    ]
}
  1. 安装调试以来,注意只能本地安装,不要全局安装,不然路径无法识别

npm install typescript ts-node tsconfig-paths

  1. 设置断点,F5 调试
参考文档