Setup a Local Node.js Web Server

This article is part of a series with the name IoT Remote Power Switch – Project Part 3.

It logs my steps how to install MongoDB, npm, and Node.js on my local Ubuntu 14.04 LTS development host. It is my local Node.js web server for developing and testing my IoT web application. Later, when I will publish it in the Internet I’ll need these components in a PaaS provider environment. I’ll come to that, for now I’ll focus on the local installation.

So, I have my Ubuntu machine connected to the Internet, my browser open and a command line console ready. The basic plot is simple, here it comes.

Install MongoDB

In my case, it installs MongoDB version 3.0.7.

Install npm

While looking for instructions how to do that I find this page: How To Install Node.js on an Ubuntu 14.04 server. I’m tempted to follow the last method called How To Install Using NVM. I use it and it works fine.
I end up having nvm version 0.16.1, npm version 2.14.3, and Node.js version 4.1.0 installed.

Install Node.js

I get that for free, see the last step. However, if you’d like to install and use a different version of Node.js, you’d just have to type (replace the version with yours):

$> nvm install 0.11.13
$> nvm use 0.11.13

With nvm you can have multiple Node.js versions installed on your machine, and select which one is active. It will run when you type node and hit <Enter> on the console.

Summary and Outlook

That’s it already! After getting acquainted with the interfaces of Node.js, npm and nvm, I shall program the Node.js web server such that it displays my front-end web page.