简体   繁体   English

无法打开Chrome到正确的URL以调试Node.js脚本

[英]Cannot open Chrome to the right url for debugging Node.js script

I run this at the command line: 我在命令行运行:

$ node --inspect --debug-brk  test/src/dev/node/define/1.test.js
Debugger listening on ws://127.0.0.1:9229/93a5524a-ae0a-4aa2-a985-3cd6ac6a2b9f
For help see https://nodejs.org/en/docs/inspector

normally this commands spits out a url that I copy and paste to the browser. 通常这个命令吐出一个我复制并粘贴到浏览器的URL。 At some point it also auto-opened Chrome to the right url so I could start debugging immediately which was very nice. 在某些时候它还自动打开Chrome到正确的URL,所以我可以立即开始调试,这是非常好的。 But now it doesn't log the url to open, nor does it auto-open the url! 但是现在它没有记录打开的网址,也没有自动打开网址! Damn. 该死的。

Note that the following url is not the right one to open: 请注意,以下网址不是正确的网址:

ws://127.0.0.1:9229/93a5524a-ae0a-4aa2-a985-3cd6ac6a2b9f

Anybody seen this with Node.js versions 6+? 任何人都看到Node.js版本6+?

I don't know why the url is no longer being printed in the console, that's a mystery, but if you look at the docs: 我不知道为什么url不再在控制台中打印,这是一个谜,但如果你看一下文档:

https://nodejs.org/en/docs/inspector/#chrome-devtools-55 https://nodejs.org/en/docs/inspector/#chrome-devtools-55

it says: 它说:

Chrome DevTools 55+ Chrome DevTools 55+

Option 1: Open chrome://inspect in a Chromium-based browser. 选项1:在基于Chromium的浏览器中打开chrome:// inspect。 Click the Configure button and ensure your target host and port are listed. 单击“配置”按钮,确保列出目标主机和端口。 Then select your Node.js app from the list. 然后从列表中选择您的Node.js应用程序。

Option 2: Install the Chrome Extension NIM (Node Inspector Manager): https://chrome.google.com/webstore/detail/nim-node-inspector-manage/gnhhdgbaldcilmgcpfddgdbkhjohddkj 选项2:安装Chrome扩展程序NIM(节点检查器管理器): https//chrome.google.com/webstore/detail/nim-node-inspector-manage/gnhhdgbaldcilmgcpfddgdbkhjohddkj

I think one of these options will work for users that face the issue in the OP. 我认为其中一个选项适用于在OP中遇到问题的用户。 Both are working for me. 两者都在为我工作。 Using NIM, I switched it to auto-open and it started auto-opening again for me, which is great, not sure why it was ever turned off. 使用NIM,我将其切换为自动打开,它再次为我自动打开,这很棒,不知道为什么它被关闭了。

I am using the following link to see all remotely connected debuggers: chrome://inspect/#devices 我使用以下链接查看所有远程连接的调试器: chrome:// inspect /#devices

Run the debugger, open the above link in chrome and you should see there a link to connected debugger 运行调试器,在chrome中打开上面的链接,你应该看到一个指向连接调试器的链接

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM