在 Mac 上的 VSCode 中调试 Javascript



我使用VSCode作为我的主编辑器,但是当我调试纯原生JavaScript时,我总是在浏览器中完成。 原因?因为我无法让调试器工作。

这在原生JavaScript中可能吗?

我已经尝试过chrome调试器扩展,但这总是超时。

我的javascript文件中只有一行代码

document.write("Hello World!");

我真的很想在 vscode 中使用调试器,但我运气不佳。

节点版本设置为 v8.1.2

这是我的launch.json配置:

{
"version": "0.2.0",
"configurations": [
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${file}",
        "cwd": "${workspaceRoot}",
        "outFiles": ["${workspaceRoot}]/*.js"]
    }
]
}

我还需要做什么?

我能够在 Ubuntu 上做同样的事情,它也应该在 Mac 上运行,使用以下配置:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch index.html",
            "type": "chrome",
            "request": "launch",
            "file": "${workspaceRoot}/index.html",
            "userDataDir": "${workspaceRoot}"
        }
    ]
}

显然,我的html文件名为index.html并驻留在工作区根目录中。

最新更新