ts调试 tsx

99 阅读1分钟

安装 tsx

npm install tsx --save-dev | npm install tsx -g

创建 launch.json 文件

文件如写入如下内容

{
  // 使用 IntelliSense 了解相关属性。
  // 悬停以查看现有属性的描述。
  // 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "tsx",
      "type": "node",
      "request": "launch",

      // Debug current file in VSCode
      "program": "${file}",

      /*
       * Path to tsx binary
       * Assuming locally installed
       */
      "runtimeExecutable": "tsx",

      /*
       * Open terminal when debugging starts (Optional)
       * Useful to see console.logs
       */
      "console": "integratedTerminal",
      // "internalConsoleOptions": "neverOpen",

      // Files to exclude from debugger (e.g. call stack)
      "skipFiles": [
        // Node.js internal core modules
        "<node_internals>/**",

        // Ignore all dependencies (optional)
        "${workspaceFolder}/node_modules/**"
      ],
      "cwd": "${workspaceRoot}",
      "internalConsoleOptions": "openOnSessionStart"
    }
  ]
}