How to install grunt and how to build script with it

前端 未结 4 1823
傲寒
傲寒 2020-12-04 05:33

Hi I\'m trying to install Grunt on Windows 7 64 bit. I have installed Grunt using commands

 npm install -g grunt
 npm install -g grunt-cli

4条回答
  •  没有蜡笔的小新
    2020-12-04 05:46

    You should be installing grunt-cli to the devDependencies of the project and then running it via a script in your package.json. This way other developers that work on the project will all be using the same version of grunt and don't also have to install globally as part of the setup.

    Install grunt-cli with npm i -D grunt-cli instead of installing it globally with -g.

    //package.json
    
    ...
    
    "scripts": {
      "build": "grunt"
    }
    

    Then use npm run build to fire off grunt.

提交回复
热议问题