在Nodejs升级到8.0之后安装 $ npm install -g node-inspector 会提示报错,由此去node-inspector的讨论区找了问题的解决方案。
果然在讨论区发现同样问题的产生,及如何解决的过程,链接地址https://github.com/node-inspector/node-inspector/issues/1013。
通过提示找到node-inspect组件可以替换,链接地址https://github.com/nodejs/node-inspect,$npm install --global node-inspect,使用文档地址https://nodejs.org/api/debugger.html。
安装之后我们就可以启动程序进行调试了,过程如下:
1、node --inspect index.js;
然后会提示如下信息
Debugger listening on ws://127.0.0.1:9229/6a2dd365-9d79-4ea0-9d1e-e37ecbe55452
For help see https://nodejs.org/en/docs/inspector
Debugger attached.
app started at port 3000
2、在chrome中的地址栏输入chrome://inspect/#devices
可以看到如下

点击Configure,
在弹框中添加地址

完成之后即可看到我们对应的项目

此时点击inspect 即可进入调试。

网友评论