Node. js debugging skills, node. js debugging

Source: Internet
Author: User
Tags node inspector

Node. js debugging skills, node. js debugging

Author: zhanhailiang Date:

1. console. log

Similar to front-end debugging, code debugging is performed by printing related variables step by step.

2. Use the Node. js built-in Debugger

Debug through node debug xxx. js:

[root@~/wade/nodejs/professional-nodejs/chapter18]# node debug app_with_bug.js < debugger listening on port 5858connecting... okdebug> helpCommands: run (r), cont (c), next (n), step (s), out (o), backtrace (bt), setBreakpoint (sb), clearBreakpoint (cb),watch, unwatch, watchers, repl, restart, kill, list, scripts, breakOnException, breakpoints, version

3. Use Node Inspector for debugging

1). Install

npm install -g node-inspector

2) Start Node Inspector (Listening to port 8080 by default)

[root@~/wade/nodejs/professional-nodejs/chapter18]# node-inspector Node Inspector v0.7.4Visit http://127.0.0.1:8080/debug?port=5858 to start debugging.

3). Run the application (run the application through-debug or-debug-brk)

node --debug-brk app_with_bug.js

4). Access http: // ip: 8080/debug through Chrome? Port = 5858, now you can use Chrome Inspector for interface debugging, as shown below:


4. Reference

<Professional Node. js> Chapter18 Debugging Modules and Applications

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.