Why use Node.js ?
Visit the node.js website and click the “Download Button” under the big Install Button.
Depending on what type of Operating System you are using, select the appropriate type. In my case, I have a windows 64-bit, so I have downloaded the first (msi) download:
When download is complete, run the file and keep clicking “next” until installing starts. Click Finish when install is complete.
Lets just make sure Node is successfully installed.
To launch node – Open the cmd (command-line) and type:
node – this is the command given to launch node. A new line should appear with the symbol “>” as shown below
To close node you will need to press “CTRL + C” and it will ask you to press “CTRL + C” again to exit. Once you press “CTRL + C” twice, node will exit.
Running Hello World using Node
Now lets create a simple “Hello World” print using node. Open the cmd (command-line) and type:
mkdir HelloWorldFolder – this will create a new folder named “HelloWorldFolder”
cd HelloWorldFolder – this will change directory and enter the new folder “HelloWorldFolder”
Now open the new created folder in windows form if you feel more comfortable and create a file name “test.js”
Open the new file using a simple text editor and paste only the following to display Hello World on-screen:
// Call the console.log function.
Back to command line to run the js file and type:
node test.js – this will run the file “test.js” in node
As you can see below node is running the js file and printing “Hello World” on the screen.
Pretty quick and easy.. enjoy 😉