nodejs 調試技巧

來源:互聯網
上載者:User

標籤:

1, 命令列調試

run 執行指令碼,在第一行暫停
restart 重新執行指令碼
cont, c 繼續執行,直到遇到下一個斷點
next, n 逐步執行
step, s 逐步執行並進入函數
out, o 從函數中步出
setBreakpoint(), sb() 在當前行設定斷點
setBreakpoint(‘f()’), sb(...) 在函數f的第一行設定斷點
setBreakpoint(‘script.js’, 20), sb(...) 在 script.js 的第20行設定斷點
clearBreakpoint, cb(...) 清除所有斷點
backtrace, bt 顯示當前的調用棧
list(5) 顯示當前執行到的前後5行代碼
watch(expr) 把運算式 expr 加入監視列表
unwatch(expr) 把運算式 expr 從監視列表移除
watchers 顯示監視列表中所有的運算式和值
repl 在當前上下文開啟即時求值環境
kill 終止當前執行的指令碼
scripts 顯示當前已載入的所有指令碼
version 顯示 V8 的版本

2, TCP 調試

$ node --debug-brk debug.js
debugger listening on port 5858


$ node debug 127.0.0.1:5858
connecting... ok

nodejs 調試技巧

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.