Step 1: Download and Installs Node.JS
Before you begin to do anything you need the software installed, and so let's head on over to the official node.js website and download the Node.js installer for Windows. It's a fairly straight forward download. You pick your Windows version, 32 or 64 bit and you download and install it. After you install it, nothing happens pretty much, but it's there and ready to be run you can be sure of that.
Open up your command line interface. You can do that by holding the Windows key and typing 'r' (Run window opens) and then typing cmd into the search field. Or any other way that you prefer to open up your command line interface.
Step 2: Run A Few Test Commands
npm command screen
If you already have npm installed then this test is moot, and so
var a = 1;
var b = 2;
var c = 3;
console.log("a: " + a);
console.log("b: " + b);
console.log("c: " + c);
console.log("a + c: " + (a + c));
And here is what that looks like when we run it:
As you can see Node read the file and executed all of the commands present right on my machine no browser required.
Step 4: Run The Interactive Tutorial
The best way to learn is by doing, and NodeSchool.io has a fantastic Node.js interactive tutorial that you can download and install through the npm package manager that will show you the basic use cases and scenarios that you will encounter when using node.js. So let's set that up. Go into your command line, like we did above, and type the following command:
npm install -g learnyounode
Let your command buzz and whir for a minute or two (it took a while on my machine) after this while everything gets installed. Once done, simply run the tutorial with the following:
And you'll get the following. A series of 13 interactive tutorials to help you wade your way through the many intricacies of Node.js. After you complete each exercise, your result will be verified and upon completion will be marked as "Complete". Pretty nifty if you ask me. So let's run through the first exercise on the list while we're here.
learnyounode home screen
The exercises start off pretty simple and get progressively more complex as you complete them. Here's the first exercise, in which our task is to output "HELLO WORLD" using node.js onto the console window.
learnyounode exercise 1
Save that, and place it in a directory that's easy to reach from the command line (something close to the C:/ drive perhaps) and we run that script using the learnyounode verify program.js command and we are done with Exercise #1.
By the time we're done with all of the exercises we'll be running our own server written in Node and doing many more cool things. I'm only going to cover Example #1 and leave the rest of the exercises up to those who enjoy learning for themselves. And I myself will be tackling on more complex node examples while I'm at it. And I'll have a follow up soon as to how that is going.
Did you find this article helpful?
Walter G. is a software engineer, startup co-founder, former CTO of several tech companies and currently teaches programming for a coding bootcamp. He has been blogging for the past 5 years and is an avid BMX rider, bio-hacker
and performance enthusiast.