[英]Cannot find Node process using VSCode Debugger
I'm testing out the VS Code node debugger, but I'm not able to find any node processes when trying to attach to a running process. 我正在测试VS Code节点调试器,但是在尝试附加到正在运行的进程时无法找到任何节点进程。
This is my launch.json file: 这是我的launch.json文件:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "attach",
"name": "Attach by Process ID",
"processId": "${command:PickProcess}"
}
]
}
the contents of my package.json file: 我的package.json文件的内容:
"scripts": {
"start": "node --inspect=0.0.0.0:9229 ./bin/www"
}
After I start up the process using 'npm start', I press 'start debug' and the list of node processes is: 使用'npm start'启动进程后,按'start debug',节点进程的列表为:
Looks like this and none of these are the server I just launched. 看起来像这样 ,而这些都不是我刚刚启动的服务器。 This list persists even after I take down the node server.
即使关闭了节点服务器,该列表仍然存在。
Why am I not able to see any of my running node processes in the VSCode process attach? 为什么我在VSCode进程附件中看不到任何正在运行的节点进程?
Ps I'm closely following this tutorial on debugging Node.js with VS Code. 附言:我正在密切关注本教程,以使用VS Code调试Node.js。
Are you running the NodeJS in debug mode inside npm start
? 您是否在
npm start
以调试模式npm start
? You need to use the --inspect
flag. 您需要使用
--inspect
标志。 Without this flag, the NodeJS interpreter won't open the debug port to the VSCode to attach to. 没有此标志,NodeJS解释器将不会打开要附加到VSCode的调试端口。
Refer to: https://nodejs.org/en/docs/guides/debugging-getting-started/ 请参阅: https : //nodejs.org/en/docs/guides/debugging-getting-started/
Another option is to attach using a port definition. 另一种选择是使用端口定义进行附加。 I usually do something like this in the launch.json:
我通常在launch.json中执行以下操作:
{
"type": "node",
"request": "attach",
"name": "Attach",
"port": 9229,
"restart": true,
"sourceMaps": true,
"protocol": "inspector"
}
Then I start the NodeJS process as: node --inspect=0.0.0.0:9229 start.js
然后我以以下方式启动
node --inspect=0.0.0.0:9229 start.js
进程: node --inspect=0.0.0.0:9229 start.js
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.