npm and jslint

So I’ve been playing around more and more with node package module (npm) and had some findings to share with my fellow JavaScript developers. For those who haven’t used NPM before, it is a collection of packaged JavaScript modules that run as services through nodeJS. Think of them as applications, written entirely in JavaScript, that you can use to help with your own JavaScript development.

  1. It’s awesome.
  2. It’s elegant.
  3. It can make no sense whatsoever until you figure out certain principles.


nodeJS is a JavaScript run time that runs from a command prompt. Its not a browser, but the JavaScript engine of a browser. You can run statements, functions, blocks and even entire modules of JavaScript directly from the nodeJS command line.

Other developers have even published packages of JavaScript modules for others to use and npm is the mechanism of installing these modules to your local system. These modules can be used to assist with development, testing, compiling and even profiling of your Web application content.

Check out some of the modules that are available to use.

Getting to the point

There is an npm for jslint!

Linting is a very helpful way of validating JavaScript syntax for potential errors before the scripts are run in an actual browser or web app. and are popular browser-based ways of doing this. With each of these examples, you copy/paste and submit your JavaScript code into a web form and see a list of good/bad messages displayed as a result.

With NPM and nodeJS you can do this straight from the command line, and even include it as a step in a build script.

For example, say you have an external JavaScript file named scripts.js that is part of your web project. Here is how you setup jslint and use it to check a local JavaScript file.

  1. Install nodeJS
  2. Open a command prompt
  3. Type “npm install jslint -g”
  4. Type “jslint <path to your scripts.js file>”

The magic here is that when you type jslint … what is actually happening is the jslint module is started using nodeJS. It is then feeding your scripts.js file through that jslint package and producing the good/bad message results.

Cool huh? Let me know what you think.


Proud Canadian who loves running, craft beer, World travel, culture and music of all shapes & styles. I live in Toronto and love this city for how diverse and unique it is. As a Solution Architect with IBM Canada's Interactive Experience (iX&M) practice, I have the privilege of leading teams of amazingly talented people to build creative and award-winning mobile applications & solutions. I love to build things and transform chaos into awesome.

Tagged with: , , ,
Posted in Tutorial

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: