Debug in Node.js

  • Using console object: console.log(‘xxx‘);
  • Using Node.js internal debugger (v8 engine): node debug xxx.js

How to use node-inspector:
  1. In one terminal, run "node-inspector" to start the node inspector server.
  2. In another terminal, run 
     node --debug your/node/program.js
  1. Or
    node --debug-brk your/short/node/script.js // pause your script on the first line
    to start your node process.
  2. Launch Chrome or Opera, open http://127.0.0.1:8080/debug?port=5858 to launch debugger UI. (Server code can be shown here)
    • You can set breakpoint to code (although you may cannot see the breakpoint first time, click "Refresh" button on browser, you can see program will stop at the breakpoint you set last time.)

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。