问题
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.
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.
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.
回答1:
I was facing same problem, I have solved it by
1) Updated chrome to latest version and relaunched it
2) Restarted node --inspect server.js
3) Noted port number as shown here port number
4) Opened chrome://inspect and added localhost: port number noted in step 3 update connection in chrome
回答2:
Seems to be a new chrome issue: https://github.com/nodejs/node/issues/26887
来源:https://stackoverflow.com/questions/55315159/cant-debug-node-js-using-chrome-devtools