美文网首页
vscode 直接debug ts 文件

vscode 直接debug ts 文件

作者: 朱允见 | 来源:发表于2022-07-25 23:28 被阅读0次

1. vscode 直接debug ts 文件

  1. 安装 TypeScript Debugger 插件

  2. 安装依赖 npm i ts-node typescript

    注意:原来通过 -g(全局)安装的包,在调试时不生效,需要在当前目录中单独安装

    调试TS代码,依赖这两个包ts-node typescript

  3. debug 创建ts debug 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"
            }
        ]
    }
    

相关文章

网友评论

      本文标题:vscode 直接debug ts 文件

      本文链接:https://www.haomeiwen.com/subject/aobnirtx.html