Kevin Isom's avatar

Tools of the Trade: Part 1

After the initial post I reckon it’s time to get started with this series. So the first tool on my list? 

Node.js

Now I’m not talking about using node as a web server or anything like that. (That will come later) I am talking about using it for tooling. Repetitive tasks should be automated. Automating those tasks using node gives you the advantage of being able to easily use those scripts on any platform. 

For instance, you have a way you like to setup your projects so you write up a script to do just that. If you are on a mac you could write a bash script, on windows maybe powershell. But that isn’t very portable. you can do it in node, put it up on npm and you can use that script anywhere and everywhere. 

Installing Node and it’s package manager NPM is easy. Now for most installs I will recommend using chocolatey and brew (see part 0) however at one point npm wasn’t being installed correctly on the Mac. So head over to the Node.js site and download the installer or via chocolatey
C:> cinst nodejs.install

You may want to install either Visual C++ 2010 Express edition if you are on Windows, or XCode  if you are on a Mac. Even if you have Visual Studio 2012 installed VC++ 2010 is still required. These tools allow you to build native node modules. Often modules that talk to other systems like databases often require native code to work.

Next tool

Grunt - The JavaScript Task Runner

Grunt is a task runner that has plenty of available plugins for automating development tasks and is easy to write your own tasks with. You don’t have to develop on Node to use Grunt in your build process. Any build process that allows you to calls to the command line is capable of using grunt. I have it running in Visual Studio projects where it will even fail a build if something does not work.

Install Grunt from the command line

npm install -g grunt-cli

This will tell npm to download the grunt command line module and install it globally. Next go to the root of your project and run

npm init

This will ask you a few questions and create a package.json file. This file will hold your dependencies (among other purposes) 

If you want a quick win to improve your JavaScript development add this grunt file to your project.

Then just install the grunt contrib jshint module

npm install grunt-contrib-jshint —save-dev

Then when you run grunt from the command line your JavaScript files will be linted using JSHint.

I will be building on that grunt file as this series progresses.

In Conclusion

Node and Grunt are great tools to improve your Front End Development no matter what platform you target for development or deployment.