[英]Node js debugging not working in Visual Studio code (year 2020)
I have gone though similar questions and none of the answers help perhaps because the configurations have changed in the latest VS Code or they are not relavant.我已经解决了类似的问题,但没有一个答案有帮助,可能是因为最新的 VS Code 中的配置发生了变化,或者它们不相关。
I get this error when I try to launch:尝试启动时出现此错误:
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
My launch.json
looks like this.我的
launch.json
看起来像这样。 Please note that this has become like this due to various trial and errors:请注意,由于各种试验和错误,这已经变成了这样:
{
"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}",
}
]
}
I have tried various combination of this as well:我也尝试过各种组合:
node --inspect-brk --inspect app.js
Sometimes it gives a message the dubugger is running at ws://somehexadisgits
but the break points do not hit.有时它会给出一条消息,即调试器正在
ws://somehexadisgits
处运行,但断点没有命中。
PS This is my vs code version: 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
After a few hours of frustrations this is how I solved.经过几个小时的挫折,这就是我解决的方法。
launch.json
to completely make it blank so that the button Run and Debug
becomes visible like this.launch.json
中的所有内容,使其完全空白,以便按钮Run and Debug
像这样可见。 (Earlier a dropdown was showing with the list of configurations that were added in the launch json) (之前的下拉菜单显示了在启动 json 中添加的配置列表)
Run and Debug
and select any environment.Run and Debug
和 select 任何环境。 I selected (chrome).npm start
.npm start
。 Notice the dropdown on the terminal at the bottom.JavaScript Debug Terminal
JavaScript Debug Terminal
PS later on when you don't want to run the app everytime in debug, you may select the other option in the terminal for. PS 稍后当您不想在调试时每次都运行应用程序时,您可以 select 终端中的另一个选项。 eg select default shell/powershell , Now when you run
npm start
it will start with the environment in normal node
environment and will run normally without attaching itself in the debug environment.例如select 默认 shell/powershell ,现在当您运行
npm start
时,它将在正常node
环境中启动,并且将在调试环境中正常运行而无需附加自身。 So this is how you may switch between choosing your application to run in debug environment or without it by selecting any of these options from the drop-down in the VS terminal.因此,您可以通过从 VS 终端的下拉列表中选择这些选项中的任何一个,在选择应用程序在调试环境中运行或不使用它之间进行切换。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.