Somebody Went and Made Node.js All Easy! o_O

I get busy learning some other things and Node.js gets all easy! I’m impressed. ๐Ÿ™‚

1. Navigate to the main node.js site, there’s a big “Download” button that you can’t miss.

The Node.js Site, Just Click It And Get It...

The Node.js Site, Just Click It And Get It...

2. Click that download buttonย and you’ll be presented with this crazy easy screen to pick your download.

Node.js Download Link...

Node.js Download Link...

3. Once you get that installed, get nodeunit. You are writing unit tests against your node code right? ๐Ÿ˜›

npm install nodeunit
Results from loading nodeunit with npm install.

Results from loading nodeunit with npm install.

For more on how to use npm, which stands for Node Package Manager, give a RTFM. ๐Ÿ˜€ ย It’s kind of like Nuget for .NETters and Gems for Rubyists. ย ๐Ÿ™‚ …and trust me, I’ll be putting this to use in future blog entries and it’s a big help to have handy.

4. Create a file to code some javascript in. Per the simple example given on the main node site…

var http = require(‘http’);

http.createServer(function (req, res) {ย  ย  res.writeHead(200, {‘Content-Type’: ‘text/plain’});
res.end(‘Hello World\n’);}).listen(1337, "127.0.0.1");

console.log(‘Server running at http://127.0.0.1:1337/’);

Now run this. If you have the Webstorm IDE from Jetbrains you can just right click on the js file and select run. It automatically will use Node.js to execute your JavaScript. You can also execute node.js by opening up a shell/terminal and executing this.

node whereverYourPathIsTheFileIsLocated/example.js

Navigate to 127.0.0.1:1337 and you’ll get the classic “Hello World” message.

Running The Node.js Example.js File

Running The Node.js Example.js File

…and all of a sudden you’re using node.js to hack some javascript! Seriously, there aren’t many usable languages out there that are as code ready as javascript with node. Very cool, very very cool.

Happy coding!