Home > Web Front-end > JS Tutorial > A simple analysis of node.js debugging methods

A simple analysis of node.js debugging methods

不言
Release: 2018-07-14 11:22:01
Original
2258 people have browsed it

This article mainly introduces a simple analysis of the debugging method of node.js. It has certain reference value. Now I share it with you. Friends in need can refer to it.

Debugging ability is programming One of the basic qualities is that quickly locating bugs can allow developers to get off work on time and avoid the pain of overtime. As we all know, JavaScript debugging is very convenient. As long as you open the browser and press F12, console.log or break points, you can always easily locate the error. Even many errors are immediately clear by looking at the error messages reported on the console. So how to debug node.js?

Use chrome plug-in NIM

Refer to the debug method on the official website. First install the chrome plug-in NIM (requires scientific Internet access) and then execute the file that needs to be debugged. For example, if there is a test.js file, enter it in the terminal. node --inspect-brk test.js Then chrome will automatically create a new page for you to debug. Below are the graphic steps

(Reference article: High-efficiency PHP debugging error prompt tool: the latest version of PHPstorm Detailed explanation of xdebug configuration and use (picture)

Write something just like that

A simple analysis of node.js debugging methods

Install in the chrome app store NIM (if you cannot access it, you can search Google Access Assistant for scientific Internet access)
A simple analysis of node.js debugging methods

After the installation is completed, run the node.js file directly
A simple analysis of node.js debugging methods

Browser A page will be automatically opened for debugging. The breakpoint debugging method is no longer described
And here you can see why each file in node.js is a separate module, and the code of each file is wrapped in in a function. You can also observe the function call stack to study node.js more deeply

A simple analysis of node.js debugging methodsvscode debugging

vscode is an editor from Microsoft that comes with its own debugging function. If you have not used it, download and install it. If you have used it, open vscode directly

A simple analysis of node.js debugging methods

Click the icon in the red circle
A simple analysis of node.js debugging methods

will open a json The configuration file appends a line of configuration to the object in configurations

"configurations": [
        {
            // here is somecode
            "cwd": "${cwd}"
        }
    ]
Copy after login

ctrl s save
You can directly break the point on the left side of the current line of code, and then click the triangular green button in the upper left corner of the editor to start debugging . And you can step into step out like chrome for breakpoint debugging

A simple analysis of node.js debugging methods

That’s it. There are many ways to debug, such as debugging directly in the code. Follow up Time will continue to be updated

The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

The above is the detailed content of A simple analysis of node.js debugging methods. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template