NodeJS NPM Grunt Grunt-cli

Source: Internet
Author: User


1. After the installation of the Nodejs, NPM will generally be installed. Nodejs integrated with NPM, you can view their version by running Node-v and npm-v in CMD separately, assuming the display shows you can continue with the following actions


2. If you want to install grunt, you can normally run NPM install grunt grunt-cli directly inside CMD, "However, except for the first time I write this can take effect. It didn't work out, what the hell? I do not know, can change to write like this:

NPM install-g grunt-cli     Install global GRUNT-CLI
NPM install-g Grunt    Install global grunt
", which means installing the [install global [-G] grunt and grunt client[cli] via NPM, or uninstalling grunt NPM uninstall-g Grunt


3. Check to see if the grunt is installed. You can run grunt-version with CMD to see the version number of Grunt as shown in the following hypothesis:Grunt-cli v0.1.9Grunt v0. 4.1 Two contains information about the client and the grunt. So that means the grunt is installed?

4. Now that we have installed the grunt, now we want to build a new project, then how to develop project documents? Enter "F:" in cmd, which means to enter F, of course, assuming your project is the same with other disks. Re-cmd inside enter "CD pathname" [Enter project folder under F Disk]

5. Open the project file in My computer new Package.json file [for managing dependent plugins],

Add for example the following: the number of references can be

{

" name ": " My-project-name " , //project name

" version ": " 0.1.0 "

" devdependencies ":  //dependent file

{

"Grunt":"~0.4.1",//"Tool file name": "~ Tool filename called version number"

" Grunt-contrib-jshint ": " ~0.6.0 " ,  

" Grunt-contrib-nodeunit ": " ~0.2.0 " ,  

" Grunt-contrib-uglify : "~0.2.2"  

}}

6. After adding the Package.json file, you need to run the operation via NPM

Then 4 steps, enter the ' npm install ' carriage return to install the Package.json inside the plugin

7. Installed Packge.json inside, now back to my computer---project directory--new file Gruntfile.js to operate the tool plug-in Package.json

Add content such as the following: references

module.exports = function (grunt)
{
    Grunt.initconfig ({
        Pkg:grunt.file.readJSON (' Package.json '),//import Package.json
        concat: {//required to run the plugin name
            WEBQQ: {//project name
  & nbsp             files: {//The name of the file to be manipulated
                    ' dist/main.js ': [' main.js ', ' drag.js ', ' scale.js ', ' range.js ']
               
           }
       }
   });
    grunt.loadnpmtasks (' grunt-contrib-concat ');//load Plug-in
    grunt.registertask (' Default '), [' concat ']); /Run plug-in
};

8. After adding the gruntfile.js plug-in operation file, the same needs to be run in CMD, followed by the 6th step input ' grunt ' to perform grunt on the project,

cmd now includes " done,witout errors. "Tips for managing the project after running the grunt




NodeJS NPM Grunt Grunt-cli

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.