Introduction To Node.js

I've been developing alot of Node.js applications lately and though I might start a new category on this blog with articles on Node.js.

Node.js is an asynchronous event driven JavaScript runtime built on Chrome's V8 JavaScript engine. It is deisnged to build scalable networking applications but can also be used to develop applications with GUI's using thrid party libraries. The Node Package Manager (npm) allows you to install third party packages either from the npm repository or install a local package from your computer.

Getting Started

Node.js is extremly simple to install on all OS platforms. On Windows there is an installer, which guides you through the setup process. For Ubuntu users simply type the following command.

sudo apt-get install nodejs
Once the process has completed, you can verify, if Node.js is installed correctly by typing the following command.

nodejs --version
Node Packager Manager (npm) is installed by default when you install Node.js. You can verify if npm is installed by typing the following command.

npm --version
Now that Node.js is installed, you can write your first program. Open a text editor and write the famous Hello World program. Save the file as app.js.

Listing 1

console.log("Hello World");

To execute the code, cd into the directory where app.js is located in a terminal or command prompt and type the following command.

nodejs app.js
You should now see Hello World printed to the terminal. This example doesnt demonstrate a lot but in the next few articles you'll become to relaise just how powerful Node.js is.