使用Chrome浏览器调试nodejs代码 转载:https://blog.csdn.net/zhouzying/article/details/98960721

今天给大家分享一下在chrome浏览器上调试nodejs代码的步骤。下面是操作:

第一步,在命令行输入调试命令:
node --inspect-brk app.js
这是调试命令的一些参数(来自官网的):

Command-line options
The following table lists the impact of various runtime flags on debugging:

Flag Meaning
--inspect
Enable inspector agent
Listen on default address and port (127.0.0.1:9229)
--inspect=[host:port]
Enable inspector agent
Bind to address or hostname host (default: 127.0.0.1)
Listen on port port (default: 9229)
--inspect-brk
Enable inspector agent
Listen on default address and port (127.0.0.1:9229)
Break before user code starts
--inspect-brk=[host:port]
Enable inspector agent
Bind to address or hostname host (default: 127.0.0.1)
Listen on port port (default: 9229)
Break before user code starts
node inspectscript.js
Spawn child process to run user's script under --inspect flag; and use main process to run CLI debugger.
node inspect --port=xxxx script.js
Spawn child process to run user's script under --inspect flag; and use main process to run CLI debugger.
Listen on port port (default: 9229)
--inspect-brk参数后面也能指定端口,未指定就使用默认的9229端口。

第二步,打开chrome开始调试:
1.在地址栏中输入:chrome://inspect

2.出现如下图所示的情况:

 

 这时候点击, 绿色字体那块,open dedicated DevTools for node.

3.于是就会出现调试页面:

 

于是我们就可以开始调试node代码了。
————————————————
版权声明:本文为CSDN博主「Jasonzhiying」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zhouzying/article/details/98960721

posted on   我和你并没有不同  阅读(314)  评论(0编辑  收藏  举报

编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示