Search code examples
node.jsinstallationubuntu-serverpackage-management

Installing NodeJS on Ubuntu 16.04 Server with the Package manager installs only the distro version (v.4) instead of LTS


I have this odd problem that when I try to install NodeJS on a fresh Ubuntu Server VM.

I execute the two simple steps from the official instruction but somehow I manage to fail.

In the home directory of my user I execute curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash - which ends successfully and then sudo apt-get install -y nodejs but this results in the installation of v.4.2.6.

Output can be seen below:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/3161 kB of archives.
After this operation, 13,2 MB of additional disk space will be used.
Selecting previously unselected package nodejs.
(Reading database ... 97187 files and directories currently installed.)
Preparing to unpack .../nodejs_4.2.6~dfsg-1ubuntu4.1_amd64.deb ...
Unpacking nodejs (4.2.6~dfsg-1ubuntu4.1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up nodejs (4.2.6~dfsg-1ubuntu4.1) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode

Please help.


Solution

  • The answer was hiding in this thread: Installing NodeJS on Ubuntu Trusty

    So it must have been some kind of an issue with curl using the local network so I used wget to download like this:

    wget https://deb.nodesource.com/setup_6.x

    And then from the same directory:

    sudo bash ./setup_6.x

    And finally:

    sudo apt-get install nodejs

    Which did it.