Web Development and other random geek stuff

Menu

First off I want to say Happy New Year to you all. One of my resolution is to blog a lot more about some of the projects I’m working on. This post will be the first in a series of post that I’ll be making about a multiplayer html5 game I’m developing with PhoneGap.

I’m not 100% sure how many post I’ll make in this series but I will make sure I cover all of the key steps. Please make sure you subscribe to my blog and get emailed an update whenever there’s a new post. Also comment below with any feedback or questions you have.

After you SSH into your Linux server (I’m using Ubuntu 14.04) you’ll need to run the following command to install Node.js.

sudo apt-get update
sudo apt-get install nodejs

Now run the following command to confirm node has installed successfully and determine which version of node installed.

nodejs -v

It shows that Node.js version 0.10.25 was installed on my system. You may get a newer version when you run your install.

*Note* we have installed Node.js as “nodejs” not “node” due to a conflict with another package in Ubuntu, so make sure you note in any Node.js code you run that you reference “nodejs” and not “node”.

Installing NPM

NPM stands for Node Package Manager and is a super easy way to install new packages (kind of like plugins) into your nodejs installation such as Socket.io. To install NPM we’ll run this one simple command.

sudo apt-get install npm

You can also check to make sure NPM installed properly and check the version number by running:

npm -v

Installing Socket.IO with NPM

Now that NPM is installed we can now install our first package Socket.io with the following command:

npm install socket.io

To confirm the socket installation along with version you would run:

npm list

This command may give you a long list of package but you’ll just be checking to make sure socket.io is listed with a version.

That’s it!

Stay tuned for my next post where we’ll be actually getting into some Node.JS coding and playing around with socket.io.