Installation and configuration of Node debugging tool JSHint

Source: Internet
Author: User

Now we will introduce a JS Code verification tool JSHint that checks for simple errors under Node.

For details about JSHint, refer to the normalization of JS code in the region (including the server and client. It provides a configuration method to allow developers to define the compliance errors themselves. This brings great convenience to developers, because in the development process, especially in the development process of the team, various problems caused by non-compliance are often encountered, or some common text errors, such as using undefined functions or parameters.

1. Install JSHint.

Open the cmd command window and enter the following command:

Copy codeThe Code is as follows:
Npm install-g jshint //-g indicates global use

NOTE: If npm is not an internal or external command, you may not have installed node or npm. For more information about the installation process, see http://dailyjs.com/2012/05/03/windows-and-node-1 /.

2. Run JSHint.

Open the cmd command window, use cd to switch to your corresponding application directory, and enter the following command:

Copy codeThe Code is as follows:
Jshint my_app.js

Note: my_app.js is the file you intend to verify or check.

3. Configure JSHint.

JSHint provides a configuration method that allows you to define verification rules based on your team or interests. You can copy the rule file at https://github.com/jshint/node-jshint/blob/master/.jshintrc.

Method 1: If you name the copied rule file. the jshintrc file is stored in the corresponding directory or parent directory. When JSHint is run, the rule file is automatically retrieved and used.

Method 2: If you do not name the rule file as a rule-compliant name (that is. jshintrc), you can manually specify the rule file when running JSHint. For example, you name the rule file jshint. json. Run the following command to run JSHint and apply your rules:

Copy codeThe Code is as follows:
Jshint my_app.js -- config/root/application/jshint. json // specify the path of the Rule File

4. configuration file rules.

There are many rules for the configuration file, including whether to use a semicolon or not, and the upper-case letter of the class constructor function. The specific rules are not described here. For details, refer to http://www.jshint.com/docs /.

By using the JSHint tool, you can check out many common errors or accidentally incorrect codes in your JS Code. Of course, JSHint will not be powerful enough to check for all your errors. But don't worry. There are several other debugging tools that can be used for Node. This time I will only introduce JSHint.

The above is my humble opinion. If you have any errors, please note. Welcome to discussion.

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.