The Linux Page

Running a specific version of Node.js

The Node.js environment is a backend server-side JavaScript environment which is being used more and more.

Under Ubuntu, we generally get pretty far behind on a TLS version. Ubuntu 16.04 offers a version 4.x when we now have 8.x avaiable! There are many reason for that problem, but that's not the point of this post...

So, I wanted to write a Zapier App. They only run your Zap tests if you have version 6.10.2. Any other version will break their test system because you cannot hope that a test will work perfectly between versions.

Therefore, I had to install the correct version. I found quite a few pages that tell you how to install a new major version. This is done by adding a PPA to your APT sources and then installing the latest sub-version of that major version. So for version 6.x, I did the following:

$ curl -sL | sudo -E bash -
$ sudo apt-get install nodejs

This works great, only it installed 6.11.2 and there are no options to install an older version.

In fact, looking at the available versions, I could not see anything else than the newer 6.x and the default Ubuntu versions (4.x).

$ apt-cache policy nodejs

So I searched further and found out that I could install any version of node using the "n" tool. First I had to install "n" and then install a version, and finally you also have to make sure that version is selected.

Installation of "n":

$ sudo npm install -g n

Then install the version you're interested in:

$ sudo n 6.10.2

Finally, make sure the correct version gets started by selecting it:

$ n

When entering "n" by itself and hit enter, a list of available versions appears. Select the version you want to use (arrow up/down) and hit enter. Now you will have the correct version:

$ node -v

IMPORTANT NOTE: If you try to run Node.js with the nodejs binary, you will run the wrong version. Most likely the latest you installed using apt-get install .... In my case I get the following output:

$ nodejs -v
Syndicate content

SMS From Me Logo

SMS From Me

To automatically start one on one conversations with your online leads.


Terms of Site Index

Find the page/content you are looking for with our index.