In a word, grunt is the Mavan of the front. It is the building tool of the JavaScript world.
1. First install node. js, because grunt relies on the npm of node. js to manage and install. The final sign of the successful installation of node. JS is: Enter it under the DOS command of CMD:
Node-v npm-v //When installing node. js, the system automatically joins the command NPM into the system variable, so it can be entered in the console.
2. On the DOS interface, install grunt with the command. A module of grunt is the equivalent of a tool, and grunt is a toolkit that is assembled from a variety of tools.
NPM install-g grunt-cli //-g represents a global installation, Grunt is a server-side version, and GRUNT-CLI is the client version.
Node Package Manager, NPM
Although the above command is executed, installing GRUNT-CLI does not mean that grunt is installed. (Under DOS interface, CTRL + C exits the current command environment)
Similarly, the command to install each module: "NPM Install module name--save-dev"
NPM Install <module>--save-dev //commands for installing individual modules
4. After completing the above two steps, you can grunt the project in combat.
We know that there are pom.xml configuration files in Maven to configure project information. The same create grunt project must have two files, Package.json files, and gruntfile.js files.
Package.json: Used to save project metadata. Gruntfile.js: Used to configure or define tasks, load Grunt plug-ins.
The configuration details of the Package.json are as follows:
{
"Name": "Qmcaifu",
"Version": "1.0.1",
"description": "The Web page for HTML5",
"Main": "Index.js",
"Scripts": {
"Test": "Echo \" Error:no test specified\ "&& exit 1"
},
"Author": "Zhao, Xu-guang",
"License": "ISC"
}
After completing the Package.json and gruntfile.js two configuration files, enter the command:
Then the task in installing the Grunt cli,grunt CLI is to run the Grunt version specified by Gruntfile. This allows you to install multiple grunt versions on a single computer.
Reference blog:
1. Http://www.gruntjs.net/getting-started#cli
Do you know what a grunt is?