Rah*_*edi 10 javascript debugging node.js visual-studio-code
我已经解决了类似的问题,但没有一个答案有帮助,可能是因为最新的 VS Code 中的配置已更改,或者它们不相关。
当我尝试启动时出现此错误:
Exception has occurred: ReferenceError
ReferenceError: closeDescriptionPopup is not defined
at HTMLParagraphElement.eval (eval at E (chrome-error://chromewebdata/:14:208), <anonymous>:3:21)
at w (chrome-error://chromewebdata/:4622:845)
at L.b (chrome-error://chromewebdata/:4628:231)
at L.e (chrome-error://chromewebdata/:4627:393)
at window.jstProcess (chrome-error://chromewebdata/:4630:800)
at chrome-error://chromewebdata/:4632:56
Run Code Online (Sandbox Code Playgroud)
我的launch.json样子是这样的 请注意,由于各种尝试和错误,现在已经变成这样了:
{
"configurations": [
{
"name": "Launch Chrome",
"request": "launch",
"type": "pwa-chrome",
"url": "http://localhost:8080",
"webRoot": "${workspaceFolder}",
},
{
"name": "Attach by Process ID",
"processId": "${command:PickProcess}",
"request": "attach",
"skipFiles": [
"<node_internals>/**"
],
"type": "pwa-node"
},
{
"name": "Attach to Chrome",
"port": 9222,
"request": "attach",
"type": "pwa-chrome",
"webRoot": "${workspaceFolder}",
}
]
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过各种组合:
node --inspect-brk --inspect app.js
Run Code Online (Sandbox Code Playgroud)
有时它会给出一条消息,调试器正在运行ws://somehexadisgits,但断点没有命中。
PS 这是我的 vs 代码版本:
Version: 1.46.1 (user setup)
Commit: cd9ea6488829f560dc949a8b2fb789f3cdc05f5d
Date: 2020-06-17T21:13:20.174Z
Electron: 7.3.1
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.18363
Run Code Online (Sandbox Code Playgroud)
Rah*_*edi 10
经过几个小时的挫折后,这就是我解决的方法。
launch.json以使其完全空白,以便按钮Run and Debug像这样可见。(之前显示了一个下拉列表,其中包含启动 json 中添加的配置列表)

PS 稍后,当您不想每次在调试中运行应用程序时,您可以在终端中选择其他选项。例如选择default shell/powershell,现在运行时npm start它将以正常环境中的环境启动node,并且将正常运行而不将自身附加到调试环境中。因此,您可以通过从 VS 终端的下拉列表中选择这些选项来切换选择在调试环境中运行或不运行应用程序。