Testing your Node.js install

Okay, so we’ve managed to install node.js on Ubuntu. Before we go creating websites we’d better test it to make sure it’s running properly.

Get the installed version of Node.js

The easiest thing to do as a quick test of your install is to get the version of Node.js that you are running

node --version  

That should show you something along the lines of this:
Checking installed version of node.js

See it? Good!

Testing Node.js with the node command line interface

You can also issue Node.js commands using the command line interface. Drop into the node command line by entering node into terminal without any arguments


When you’re in the Node command line, the prompt will be a “>” instead of a “$”.

Now enter the following command to write a message back to the terminal window

console.log('Yay, node.js is installed and running');  

You should see your message returned below the command:
Node.js console.log function

To jump out of the Node.js command line and back to the standard terminal prompt press Ctrl+D.

Now that we can see our install is working, next time we’ll really get going and jump right in to creating a simple webpage in node.js.