node. js in Chrome for debugging

Source: Internet
Author: User
Tags install node

In the development of node. JS environment, debugging is a very painful thing, but with the development of the times, there are now many kinds of node environment code debugging methods, today I will note the way I use

Node-inspector:

Node-inspector interacts with users via web pages, a browser based on the WebKit kernel, such as chrome, Safari, or Maxthon (roaming browser), QQ browser, Sogou browser, etc.

To debug first install Node-inspector:

1. NPM install-g Node-inspector

2. After the installation is successful, you need to start

Locate the node-inspector file directory directly under the installation letter and enter the command directly:node-inspector to start

As you can see from the node-inspector default port of 8080, this can also be modified in the following way:

--web-port=[port]

Note: port=5858 in the URL refers to the debug port of node. JS

3. How do I debug the code next?

The Development node project basically will start from an interface point, launch this file will start the node project, the basic is node xx.js can, as long as the traditional way to add--debug or--DEBUG-BRK can

Note: –-debug and –-debug-brk differ, the former runs the script directly, while the latter pauses at the beginning of the script, waiting for the debugger to connect, and the debugger's instructions to run.

When successful, it will show

4. Go to Chrome browser debugging

Note: If http://127.0.0.1:8080/?port=5858 cannot be opened see if node-inspector is in the boot state

node. js in Chrome for debugging

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.