Nodejs is javascript for server side apps. Installing Nodejs on the remote Ubuntu server allows me to play with the same language on both server and client sides. So, I decided to give it a try.

Setup Ubuntu server

Follow the link here to setup a basic Ubuntu server droplet on DigitalOcean.

Install Nodejs

There are two methods to install Nodejs, directly or through nvm. For a quick test, I used method 1 to install Nodejs version 0.10.x.

Directly install Nodejs

Follow the instruction here to install Node.js and Nodejs package manager npm.

$ sudo apt-get update
$ sudo apt-get install nodejs
$ sudo apt-get install npm

Install with nvm package

$ nvm install stable

Then use nvm to manage and use different Nodejs versions. Here is how to use it.

Installing Node.js by this method makes it available for any user, not only root, which is unlike the one in the Nodejs application image available on DigitalOcean Control Panel.

There will be an issue of naming with both methods. Because of a conflict with another package, node, the executable Nodejs from the Ubuntu repositories is called nodejs instead of node.

Naming issue

Because most of other Nodejs-based applications use node instead of nodejs to run Nodejs apps, a symbolic link may require

$ sudo ln -s /usr/bin/nodejs /usr/bin/node

or install this

$ sudo apt-get install nodejs-legacy

Check if nodejs is installed correctly

$ node -v
$ npm -v

You may want to make another snapshot at this step

See more about node and nodejs naming here.

References

  1. New Ubuntu 14.04 Server Checklist
  2. How to Install Node.js on an Ubuntu 14.04 server
  3. Node Version Manager