You are viewing a post from electro kami classic - hello!

Install Node.js on a Vyatta server (or a Debian install)

Are you trying to install NodeJS on a Vyatta server for some weird reason? So was I!

There are quite a few hurdles you must hop over to complete this seemingly elusive task, and I just did it – so I will share my lessons learned.

0. Check the version

One of the first things you need to do is check the version of your Vyatta server. You can accomplish that by simply doing

$ uname -a

Which should output something like:

Linux cloud-server-02 3.10.61-1-amd64-vyatta #1 SMP Mon Nov 24 22:54:05 UTC 2014 x86_64 GNU/Linux

1a. Try to update your apt list

The next step is to make sure your apt repository list is up-to-date. This can be done by using the update command:

$ sudo apt-get update

1b. My apt update didn’t do anything

If nothing happens, which is what you should expect, then chances are your sources.list file is completely empty. Try this command, which will print out the contents of that file into the console:

$ cat /etc/apt/source.list

If it is in fact empty, never fear! We can fix that. All we have to do is add some sources for it to find packages.

Now you could generate a list of sources for apt to use from a website like this one, our you could try out this one from Ubuntu Trusty Tahr:

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://us.archive.ubuntu.com/ubuntu/ trusty main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty main restricted

## Major bug fix updates produced after the final release of the
## distribution.
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates main restricted

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ trusty universe
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty universe
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates universe

## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty multiverse
deb http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-updates multiverse

## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://us.archive.ubuntu.com/ubuntu/ trusty-backports main restricted universe multiverse

deb http://security.ubuntu.com/ubuntu trusty-security main restricted
deb-src http://security.ubuntu.com/ubuntu trusty-security main restricted
deb http://security.ubuntu.com/ubuntu trusty-security universe
deb-src http://security.ubuntu.com/ubuntu trusty-security universe
deb http://security.ubuntu.com/ubuntu trusty-security multiverse
deb-src http://security.ubuntu.com/ubuntu trusty-security multiverse

## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu trusty partner
# deb-src http://archive.canonical.com/ubuntu trusty partner

## Uncomment the following two lines to add software from Ubuntu's
## 'extras' repository.
## This software is not part of Ubuntu, but is offered by third-party
## developers who want to ship their latest software.
# deb http://extras.ubuntu.com/ubuntu trusty main
# deb-src http://extras.ubuntu.com/ubuntu trusty main

Copy that list, and then edit your server’s list by opening up vi. First do:

$ vi /etc/apt/sources.list

Then hit INSERT on your keyboard, paste the list into the file, press ESC, and save with:

$ :wq
# You may need to save with a bang if the file is read only:
$ :wq!

Now that you have that all setup, re-run our update and upgrade commands to update the apt repo list.

$ sudo apt-get update
$ sudo apt-get upgrade

2a. Install NodeJS: the easy way

If you’re lucky, you could now probably just use the simple way to install NodeJS onto your Vyatta server, by just asking apt to do it for you:

$ sudo apt-get install nodejs

That should result in everything being installed, which you can verify with:
$ node -v
v0.12.0
$ npm -v
2.5.1

Please note: Sometimes you need to restart your SSH session to see the Node and NPM version numbers show up correctly!

2b. Install NodeJS: the long way

If for some reason you are having issues with node or npm, you probably just want to build manually.

First, cleanup any existing installs:
$ sudo apt-get --purge remove node
$ sudo apt-get --purge remove nodejs

Make sure you have the build essential lib:
$ sudo apt-get install build-essential

If you see this error at this point in time:
Reading package lists... Done

Building dependency tree
Reading state information... Done

E: Unable to locate package build-essential

Head back up to 1b. My apt update didn’t do anything and make sure your sources.list file is populated:

Then proceed to download and install NodeJS:

$ wget http://nodejs.org/dist/v0.12.0/node-v0.12.0.tar.gz
$ tar -xzf node-v0.12.0.tar.gz
$ cd node-v0.12.0/
$ ./configure
$ make
$ sudo make install

The line where make occurs will take a while, potentially up to 15 minutes.

Once you’ve completed the make install, you should be able to verify your node install by entering in these commands.
$ node -v
v0.12.0
$ npm -v
2.5.1

3. Profit

gnomes south park

Now you have NodeJS and NPM installed! You have nothing more to do but profit in your ventures from hence forth. Let us know if you have any questions below.