Commissioning of the Nodejs (Node-inspector)

Source: Internet
Author: User

Go from:node. JS Debugging Tool node-inspector Brief description

address : Code Demo file

We are in touch with the client JavaScript, debugging tool is Firebug, is also why like to use the main power of the Firefox browser, of course, then the chrome plugin also appeared firebug figure ....

But the server-side development language node. JS has been debugging not particularly handy, perhaps by being spoiled by virtual studio, the use of Console.log () to print variables or even callback data is really lame.

Of course, there is a very powerful IDE, webstrom to node. JS provides the most comprehensive support, can also be easily configured to implement debugging, next time it is necessary to share with you.

Today's share is about debugging the node. JS program under Node-inspector.

The first step:

NPM install-g Node-inspector

Global Installation Node-inspector

[Email protected]0.9.2/usr/local/lib/node_modules/node-Inspector├──[email protected]1.0.9├──Async@0.9.0├──[email protected]3.0.1├──[email protected]1.3.3├──[email protected]1.0.4([email protected]0.6.2) ├──strong[Email protected]0.1.1([email protected]1.0.4) ├──[email protected]0.5.5([email protected]0.1.3, [email protected]0.2. One, [email protected]1.3.3, [email protected]0.0.Ten) ├──serve[Email protected]2.2.0([email protected]0.7.0, [email protected]0.2.4, [email protected]1.3.0, [email protected]1.5.1) ├──[email protected]4.5.3([email protected]2.0.1, [email protected]1.3.1, [email protected]1.0.4, [email protected]2.0.4) ├──[email protected]4.12.3([email protected]1.0.0, [email protected]1.0.0, [email protected]1.0.6, [email protected]1.1.1, [email protected]0.2.4, [email protected]0.1.2, [email protected]1.0.1, [email protected]1.0.2, [email protected]1.0.1, [email protected]0.3.4, [email protected]1.0.0, [email protected]1.3.0, serve-Static@1.9.2, [email protected]0.5.0, [email protected]0.1.3, [email protected]1.0.0, [email protected]2.4.1, [email protected]2.1.3, [email protected]1.5.1, [email protected]2.2.0, [email protected]0.12.2, [email protected]1.2.5, type- is@1.6.1, [email protected]1.0.7) ├──biased[Email protected]0.2.3([email protected]1.4.0, [email protected]1.1.0, X-default[Email protected]0.3.0, [email protected]0.4.4) ├──[email protected]0.4. +([email protected]0.0.1, [email protected]0.0.6, [email protected]2.1.0, [email protected]1.0.0) ├──v8[Email protected]0.4.2([email protected]1.7.0) └──v8[Email protected]5.2.4([email protected]1.5.3)

The code shown above shows that the installation was successful.

Step Two:

Terminal to navigate to the project root directory you want to debug

Enter the following command to start the project

Localhost:noderest hywanliyuan$ Node--58588000

The server.js above is the startup file for my project,

Next, the output monitors the debugger under Port 5858.

The bottom is the program startup file app.js output content, listen 8000

Step Three:

Open another terminal, navigate to the root directory where you want to debug the project, and enter

Node-inspector

Run to get the following results

Localhost:noderest hywanliyuan$ node-inspectornode Inspector v0. 12.8 Visit http: // 127.0.0.1:8080/?port=5858 to start debugging.

Tells us that the debugger is running under local 127.0.0.1:8080. We copy the debug address above.

Fourth Step:

Choose a browser that supports Node-inspector, you can choose Chrome or Firefox

I'm using Chrom to open:

You can see all the code on the startup page in the browser and create an endpoint with a left mouse click, such as a breakpoint I clicked before Console.log.

The right-hand interface allows you to choose to continue running, or single-step (shortcut key F10)

The interface below shows the values and outputs of the variables. It's pretty good to use, if you're debugging in single-step mode, you'll get a layer of code in the core module in depth.

Commissioning of the Nodejs (Node-inspector)

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.