【nodejs】调试

use v8.9.3 instead of v0.10.x version of nodejs

compile a debuggee

var hell = 'world';
console.log(hello.length); // undefined error

startup debuggee witho nodejs

$node --inspect-brk=0.0.0.0:12345 debuggee.js
Debugger listening on ws://192.168.56.101:12345/fcf48731-9cb2-4172-b5a6-4f63f0798661
For help see https://nodejs.org/en/docs/inspector

read json configuration from url

Paste this url into chrome

http://192.168.56.101/json

[ {
  "description": "node.js instance",
  "devtoolsFrontendUrl": "chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=192.168.56.101:12345/fcf48731-9cb2-4172-b5a6-4f63f0798661",
  "faviconUrl": "https://nodejs.org/static/favicon.ico",
  "id": "fcf48731-9cb2-4172-b5a6-4f63f0798661",
  "title": "test.js",
  "type": "node",
  "url": "file:///home/harry/workspace/bitbaba/www/test.js",
  "webSocketDebuggerUrl": "ws://192.168.56.101:12345/fcf48731-9cb2-4172-b5a6-4f63f0798661"
} ]

start to debug by pasting debugging url

Paste this url into chrome to startup debugging:

chrome-devtools://devtools/bundled/inspector.html?experiments=true&v8only=true&ws=192.168.56.101:12345/fcf48731-9cb2-4172-b5a6-4f63f0798661
通过使用VSCode来调试Node.js应用程序,你可以按照以下步骤进行操作: 1. 首先,你可以在你的JS代码中设置断点。你可以通过在终端中输入命令`node --inspect index.js`来启动Node.js进程,并且会输出一个调试地址。 2. 在VSCode中,你可以点击左侧的虫子图标打开调试面板,然后点击绿色的三角形按钮来开始调试。这将连接到Node.js的WebSocket服务,启动调试。 3. 一旦调试已经开始,你可以在VSCode中使用调试工具来逐行执行代码并监视变量的值。你还可以使用断点来暂停代码的执行以便进行调试。 如果你想调试Node.js的C源码或者Addon的C代码,可以按照以下步骤进行操作: 1. 首先,你需要在VSCode中点击调试按钮来进入调试模式。 2. 在VSCode中调试C代码时,你需要等待Node.js启动流程完成后,系统会输出一个调试JS的地址。 3. 然后,你可以在浏览器中连接到WebSocket服务,以便通过VSCode进行C代码的调试。 通过上述步骤,你可以在VSCode中方便地进行Node.js应用程序的调试,无论是JS代码还是C代码。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [vscode调试Node.js指南](https://blog.csdn.net/THEANARKH/article/details/119874093)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值