node. js Debugging Tips

Source: Internet
Author: User

  Zhanhailiang Date: 2014-11-23

1. Console.log

Same as front-end debugging, code debugging with step-by-step printing of related variables

2. Using the debugger built in with node. js

Debug via node Debug xxx.js:

[Root@~/Wade/Nodejs/Professional-nodejs/Chapter18]# node Debug app_with_bug.js<Debugger listening on port5858Connecting ... 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. Using node inspector for debugging

1). Installation

Install - G node-inspector

2). Start node Inspector (default listener 8080 port)

[Root@~/Wade/Nodejs/Professional-nodejs/Chapter18]# Node-inspectorNode Inspector v0.7.4visit http://127.0.0.1:8080/Debug?Port=5858To start debugging.

3). Run the application (via –debug or –DEBUG-BRK to the application)

--debug-brk App_with_bug.js

4). To access http://ip:8080/debug?port=5858 via chrome, you can use Chrome inspector for GUI debugging, as follows:


4. Reference

<professional node.js> Chapter18 debugging Modules and Applications

node. js Debugging Tips

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.