这是答案的一部分(而不是答案)。
到目前为止,我已经花了 2 天时间尝试相同的方法,并发现
ClearScript 不使用节点来调试 javascript 代码 =/=。
已成功运行 node.exe 并附加调试器:
节点进程列表输出为(http://127.0.0.1:9229/json/list):
[ {
"description": "node.js instance",
"faviconUrl": "https://nodejs.org/static/favicon.ico",
"id": "574da142-2ee2-44da-a912-03f96868339c",
"title": "Administrator: IA-32 Visual Studio 2008 mode - node --inspect[6416]",
"type": "node",
"url": "file://"
} ]
但它看起来一点也不像 ClearScript.V8 设备 (http://127.0.0.1:9222/):
Type: connect
V8-Version: 5.5.372.40
Protocol-Version: 1
Embedding-Host: V8Runtime
Content-Length: 0
和你的一样。
进一步阅读 V8 实现了它自己的调试协议,我没有设法找到任何权威文档。所有的互联网都有点点滴滴,但没有什么是完整的。
我已经在 Chrome 开发工具中设法识别远程设备,但除此之外,没有检查设备的选项,不知道为什么(也许我们都使用旧版本的 ClearScript 5.4.x)。
CDT > Remote Devices: Remote Target #127.0.0.1 / Target(就是这样,没有按钮,没有链接,什么都做不了)。
最后的希望是在某种程度上构建我自己的检查器,以至少查看 js 堆栈跟踪(如果没有的话)(这原本是我的目标)。
--- 编辑:结束并完成答案(对于 op、我和其他人):
找到可以正常工作的“Microsoft 代码”。对配置示例进行了一些调整,阅读了他们的帮助,但使它起作用了。
加载脚本源、断点、控制台,一切正常(如宣传的那样)。
如何:
launch.json 源代码:
{
// 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": "Launch Program (NodeJS)",
"program": "${workspaceRoot}/bin/Debug/",
"cwd": "${workspaceRoot}",
},
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId" :"${command:PickProcess}",
"cwd": "${workspaceRoot}",
},
// works with 5.5.x V8 Runtime
{
"type": "node",
"request": "attach",
"name": "Attach to CSV8:9222 (Inspector)",
"protocol": "inspector",
"address": "127.0.0.1",
"port": 9222,
},
// works with 5.4.x V8 Runtime
{
"type": "node",
"request": "attach",
"name": "Attach to CSV8:9222 (Legacy)",
"protocol": "legacy",
"address": "127.0.0.1",
"port": 9222,
},
// works with 5.4.x and 5.5.x V8 Runtime
{
"type": "node",
"request": "attach",
"name": "Attach to CSV8:9222 (Auto)",
"protocol": "auto",
"address": "127.0.0.1",
"port": 9222,
},
]
}
希望对你也有帮助