Grunt Update

This is a followup post of my previous post on “Grunt Basics.”

Apparently, installing grunt has changed since my last blog.  Pwa pwa pwa…

1. If you’re installing grunt for the first time, type this in your command line:

npm install -g grunt-cli

If you’re updating from a version before 0.4, type this:

npm uninstall -g grunt && npm install -g grunt-cli

2. For “project scaffolding,” install grunt-init:

npm install -g grunt-init

Project scaffolding is when you type a command in the command line, and that automagically builds a project directory for you.  It’ll prompt you for a project name, description, version, etc etc.  So once you’ve installed grunt-init, you can type something like:

grunt-init jquery

And that’ll set up a jQuery project for you.  That also comes with a whole bunch of stuff, like JS Hint, QUnit, Uglify… check out the package.json file to see what it comes with.  If you run:


And something’s missing, just do:

npm install

And the missing stuff gets installed.  Run:

grunt watch

And your project gets rebuilt as you save your JS files.  Yuh, it’s like magic.

So when you run:


It’ll go through all the tasks defined in your default task in your Gruntfile.js.  Usually it looks like this:

grunt.registerTask(‘default’, [‘jshint’, ‘qunit’, ‘clean’, ‘concat’, ‘uglify’]);

But feel free to configure that and anything else you may need in your Gruntfile.js.