vscode调试typescript文件

403 阅读1分钟

参考

vs code ts运行、断点调试解决方案

运行是之前就配好了,挺简单的,主要是调试

修改 .vscode 文件夹下面的 launch.json 文件(主要改 configurations)

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "this is the name you input",
      "skipFiles": [
        "<node_internals>/**"
      ],
      "program": "${workspaceFolder}/leetcode/${fileBasenameNoExtension}.ts",
      "runtimeArgs": [
        "-r",
        "ts-node/register",
        "-r",
        "tsconfig-paths/register"
      ]
    }
  ]
}

安装插件(要安装在本地,不能全局安装)

npm install typescript ts-node tsconfig-paths

然后正常调试即可