- You learn why dependency management is such a big deal.
First you load jQuery, because who wants to do serious DOM-based development without it. Then you need a calendar, and it requires a jQuery 1.6+. Now you know why services like npmJS and Bower are so useful.
- You become dependent on a script loader.
- Your source code gets so big you have to re-factor it into lots of smaller files.
Enter Grunt, the Task Runner
You install Grunt via npm, the package manager for NodeJS. If you haven't installed Node yet, download NodeJS now. Once Node is installed, you have access to the CLI tool npm.
To install Grunt, go to the console and type:
$ npm install -g grunt-cli
Great! You have installed Grunt, now what? The short version is that you need a couple of files in the root of your Web project - package.json and Gruntfile.js (or Gruntfile.coffee). Remember back at #1 when you decided you needed a dependency manager? Here you go. If you don't have a package.json file yet, go the root of your Web project in the console and type:
$ npm init
Npm will ask you a series of questions about your project. Answer as best you can, you can change these values later. Once completed, npm will generate a new package.json file that you will use to maintain your Node dependencies, like plugins for Grunt to run specific tasks.
You can then install Grunt and set it up as a dependency in package.json by typing:
$ npm install grunt --save-dev
From there, you can create a Gruntfile, add plugins, and set up tasks to automate your code/debug lifecycle. We will cover that topic in the next part of the series. Meanwhile, if you need more details, you can learn all about getting started with Grunt.