Node Debug Tool jshint

Source: Internet
Author: User

Installation and Configuration tutorial for node Debug tool jshint

Font: [Increase decrease] Type: Reprint time: 2014-05-27 I want to comment

I'm not going to brag about node's advantages, it makes it possible for JavaScript to unify the front and back of the web. But for beginners, the server side of the JS code may not be as good as the client side of the code debugging, intuitive. The debugging of client-side JS code has basically undergone a process from "naked eye--alert ()--firebug (or other developer tools)". For server-side debugging, it is possible that novices still stay in the "naked Eye--console ()" stage. In fact, node after so many years (although only a few years) development, there are a lot of good third-party debugging tools. Includes node built-in Debugging Tools debugger, Node-inspector, and more.

Now we introduce a JS code validation tool Jshint that checks for simple errors under node.

Jshint the specific introduction of reference http://www.jshint.com/about/, said bluntly, Jshint is a check JS code specification or not tools, It can be used to check any (including server side and client side) of the local JS code normative. It provides a way to configure, allowing the developer to define which specifications to check for errors. This gives developers a lot of convenience, because in the development process, especially in the team development process will often encounter a variety of problems caused by non-compliance, or some common text errors, such as the use of 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 means global use

Note: If you are prompted that NPM is not an internal or external command, you probably don't have node or NPM installed. Please refer to http://dailyjs.com/2012/05/03/windows-and-node-1/for specific installation procedures.

2, running Jshint.

Open the CMD Command window, use the CD to switch to your corresponding app directory, enter the 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, Configuration Jshint.

Jshint provides a configuration method that allows you to define the rules for checking checks according to your team or hobby. You can copy the default rule file to Https://github.com/jshint/node-jshint/blob/master/.jshintrc.

Method One: If you name the copied rule file as a. jshintrc file and place the file in the corresponding directory or parent directory, the rule file is automatically retrieved and used when you run Jshint.

Method Two: If you do not name the rule file to match the name of the rule (that is, with. jshintrc), you can manually specify the rule file when you run Jshint, for example, you name the rule file Jshint.json. Then you can use the command to run Jshint and apply your rules:

Copy CodeThe code is as follows:
Jshint my_app.js--config/root/application/jshint.json//Specify Rule file path

4, the configuration file rules.

There are a number of rules for profiles, including the usual use of semicolons or not, the first capitalization of class constructor letters, and so on. The specific rules are no longer one by one, please refer to http://www.jshint.com/docs/.

By using the Jshint tool, you will check out many of the common errors in your JS code, or accidentally mistaken code. Of course, Jshint won't be strong to check out all your mistakes. But don't worry, there are a few other debugging tools that you can use for node, this time just about Jshint.

The above is a bit of my humble opinion, if there are errors, please point out. Welcome to the exchange of discussions.

Node Debug Tool jshint

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.