无法使用Chrome DevTools调试node.js [英] Can't debug node.js using Chrome DevTools

查看:257
本文介绍了无法使用Chrome DevTools调试node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行node --inspect app.js时,它显示为附加了调试器".然后,我打开chrome://inspect,看到我的应用程序在那运行,所以我单击打开专用DevTools"或检查"(在应用程序名称旁边).不管我如何打开Node DevTools,它似乎都没有连接任何东西(我在那里看不到源代码,调试器语句被忽略,没有日志记录到控制台等).我还尝试通过打开常规DevTools并单击绿色的Node图标来打开它.

When I run node --inspect app.js it says "Debugger attached". Then I open up chrome://inspect and I see my app running there so I click either Open dedicated DevTools or Inspect (next to the app's name). No matter how I open Node DevTools though, it just doesn't seem to be connected to anything (I can't see the source code there, the debugger statements are ignored, nothing logs to the console etc). I also tried opening it by opening regular DevTools and clicking the green Node icon.

这很奇怪,因为Chrome清楚地看到服务器正在运行,并且显然有节点连接到了Node(而且我认为网络上没有其他东西可以做到这一点),但是我仍然无法让DevTools甚至承认服务器的存在.

It's weird because Chrome clearly sees the server running and something is clearly connecting to Node (and I don't think there's anything else on my network that could do that) but I still can't get DevTools to even acknowledge the server's existence.

我还清楚地记得几周前以完全相同的方式调试某些东西,然后一切正常(尽管我记得我也为此付出了一些努力,但最终还是以某种方式使它可以工作,我想附加一下名称将文件放在命令末尾而不是放在文件中间就可以了.此后发生的唯一一件事情是我从v8更新到了v10(LTS)

I also distinctly remember debugging something the same exact way a few weeks ago and back then everything worked fine (although I remember I also struggled with this a bit but I somehow got it to work at the end, I think attaching the name of the file at the end of the command instead of in putting it in the middle did the trick at the end). The only thing that's happened since then is that I updated from v8 to v10 (LTS)

我显然已经尝试过重新启动,并且还阅读了有关节点的所有手册和文章-检查那里,没有任何帮助.

I've obviously tried rebooting and also reading every manual and article about node --inspect out there, nothing helped.

推荐答案

我遇到了同样的问题,我已经通过

I was facing same problem, I have solved it by

1)将chrome更新到最新版本,然后重新启动

1) Updated chrome to latest version and relaunched it

2)重新启动节点--inspect server.js

2) Restarted node --inspect server.js

3)注意的端口号,如下所示 端口号

3) Noted port number as shown here port number

4)打开chrome://inspect并添加localhost:步骤3中记录的端口号 更新Chrome中的连接

4) Opened chrome://inspect and added localhost: port number noted in step 3 update connection in chrome

这篇关于无法使用Chrome DevTools调试node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆