Parse the debugging method of NodeJs and parse the debugging method of nodejs

Source: Internet
Author: User
Tags google developer tools install node

Parse the debugging method of NodeJs and parse the debugging method of nodejs

About debugging

When we focus only on the front-end, we use F12, which brings us a sense of security and comfort.

But when we use NodeJs for background development, I have a nightmare.

But don't worry about Thailand. It is inconvenient to debug NodeJs! This is for sure.

But fortunately, we have # node-inspector # To help us solve some debugging problems, but it is still a little powerless for NodeJs with strong asynchronous capabilities.

Node-inspector

Install node-inspector

We still use npm to install node-inspector globally.

npm install -g node-inspector

Test code

// Event. jsvar events = require ('events'); var util = require ('util'); function tianxi.pdf (name) {this. name = name; events. eventEmitter. call (this);} util. inherits (Restaurant, events. eventEmitter); // defines the role var restaurant = new tianxi.pdf ('yijian ');

This is the code to debug.

Start node-inspector

Start node-inspector first

C:\Users\Administrator>node-inspectorNode Inspector v0.12.8Visit http://127.0.0.1:8080/?port=5858 to start debugging.

All right, start successfully.

Start the debug mode of nodejs

Restart a terminal and start the debug debugging function provided by nodejs.

C:\Users\Administrator\Desktop>node --debug-brk event.jsDebugger listening on port 5858

-- Debug-brk means to start event. js in debug mode and breakpoint on the first line.

View results

In this way, two programs communicate through socket. We can debug NodeJs in our Google Developer Tools.

The following debugging process is similar to that of Js debugging.

The above is all the content of this article. I hope this article will help you in your study or work. I also hope to provide more support to the customer's home!

Related Article

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.