Why does installing node 6.x on Ubuntu 16.04 actually install node 4.2.6?
These were my steps to install node on Ubuntu 16.04:
curl -sL | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y npmwhich are the official instructions:
After doing this, running nodejs --version returns v4.2.6.
As I used setup_6.x I was assuming a version beginning with 6 would be installed?
I thought perhaps setup_6.x should be setup_6.2.1, but that page returns a 404, see:
(there is a page there)
(returns a 404)
How do I install the latest stable version of node on Ubuntu 16.04?
Edit:
These are results after running sudo apt-get install -y nodejs:
sudo apt-get install -y nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required: gyp libboost-python1.58.0 libjs-inherits libjs-node-uuid libjs-underscore libssl-dev libssl-doc libuv1-dev linux-headers-4.4.0-18 linux-headers-4.4.0-18-generic linux-headers-4.4.0-21 linux-headers-4.4.0-21-generic linux-image-4.4.0-18-generic linux-image-4.4.0-21-generic linux-image-extra-4.4.0-18-generic linux-image-extra-4.4.0-21-generic linux-signed-image-4.4.0-18-generic linux-signed-image-4.4.0-21-generic python-configobj python-pycurl python-pyexiv2 python-pyexiv2-doc
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed: nodejs
0 to upgrade, 1 to newly install, 0 to remove and 0 not to upgrade.
Need to get 0 B/3,162 kB of archives.
After this operation, 13.2 MB of additional disk space will be used.
Selecting previously unselected package nodejs.
(Reading database ... 329473 files and directories currently installed.)
Preparing to unpack .../nodejs_4.2.6~dfsg-1ubuntu4_amd64.deb ...
Unpacking nodejs (4.2.6~dfsg-1ubuntu4) ...
Processing triggers for doc-base (0.10.7) ...
Processing 1 added doc-base file...
Registering documents with scrollkeeper...
Processing triggers for man-db (2.7.5-1) ...
Setting up nodejs (4.2.6~dfsg-1ubuntu4) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto modeEdit:
Results of apt-cache policy nodejs:
apt-cache policy nodejs
nodejs: Installed: 4.2.6~dfsg-1ubuntu4 Candidate: 4.2.6~dfsg-1ubuntu4 Version table: *** 4.2.6~dfsg-1ubuntu4 500 500 xenial/universe amd64 Packages 100 /var/lib/dpkg/status 7 8 Answers
The core reason is that the setup script didn't run correctly. Therefore, thanks to the updated data from the OP which supports this, the data from the NodeSource repository was never seen by apt because it was not properly configured by the script.
The script, therefore, may not have found your distribution, or it may have messed up when configuring the repository, or there may have been a network interruption, or any of a thousand reasons it was disrupted and didn't do its job.
The fact you are seeing version 4.x getting installed means that the script didn't do its job right, so the script is not necessarily at fault. This just means we have to potentially do this a harder way.
I should point out: the script doesn't actually do any installing - all it does is determine the Debian/Ubuntu version you're on, and configure the repository for it to get data from. The installation part is actually the
sudo apt-get installstep you ran by hand.
Also of note: this will remove the
npmpackage but that's becausenodejswith this upstream packaging will includenpmwith it - no need for thenpmpackage.
Rather than rely on the script, we can do what the script is doing the old-school way: by hand, ourselves, set up the repository configuration and install NodeJS.
Here's the manual way of making this work, and it is basically what the script does (except for Step 4, which is to make sure you are getting accurate version data):
Create a new file:
/etc/apt/sources.list.d/nodesource.listYou'll need to create this file with
sudo, but when you create the file, put this inside it:deb xenial main deb-src xenial mainThen, save the file. (replace
node_6.xwithnode_7.xornode_8.x, etc. for newer Node versions)Download the GPG Signing Key from Nodesource for the repository. Otherwise, you may get
NO_PUBKEYerrors withapt-get update(usewgetin this command ifcurlisn't installed, and if neither are installed, install one of them):curl -s | sudo apt-key add -Manually run
sudo apt-get update.This refreshes the data from the nodesource repo so
aptknows a newer version exists.If you get a
NO_PUBKEYGPG error, then go back to Step 2Check
apt-cache policy nodejsoutput.This is not done by the script, but you want to make sure you see an entry that says something like this in the output (though the version might be different if you are not using 6.x as the version string; the only thing we care about is that there's a newer version number provided via nodesource):
Version table: 6.2.1-1nodesource1~xenial1 500 500 xenial/main amd64 Packages 4.2.6~dfsg-1ubuntu4 500 500 xenial/universe amd64 PackagesIf you do not see entries like this, and only see 4.2.6, start over. Otherwise, proceed.
Install the
nodejsbinary. Now that you have confirmed 6.x is available on your system, you can install it:sudo apt-get install nodejsnodejs --versionshould now showv6.2.1or similar on output (as long as it starts withv6.you're on version 6 then; this may be a higher version number if you're using a newer version than 6 but as long as it is not 4.2.6 you should be good to go).
I had an older version of node. All I needed to do was to purge the old one:
sudo apt-get purge nodejs npmAnd then, replacing 6 in v=6 with 7, 8, 9 as needed for the respective versions (see official installation instructions):
v=6
curl -sL | sudo -E bash -(be sure you have curl installed.)
And lastly,
sudo apt-get install -y nodejsBoom, latest version of node.
3For the Ubuntu 16.04.2 version user(with a little bit change from Thomas'post and thank for him )
1.open the software updater
2.setting
3.other software
4.Add the sources but remember to choose all new sources option later exp:
deb xenial main
deb-src xenial main5.reload
6.sudo apt-get update
7.apt-cache policy nodejs //to get the new version table and check if the source is setup done
8.sudo apt install nodejs
9.nodejs --version
NOW It is all set.......
warning: do not change your Linux default driver for your nvidia card from the updater panel ....the system will be crashed....!!!
2I had the same issue. But in my case I had to upgrade my curl command. You can see the issue by running with the -S option.
curl -s -S | sudo apt-key add -Which showed the issue
curl: (1) Protocol "https" not supported or disabled in libcurl
gpg: no valid OpenPGP data found.So I fixed this issue by running the following.
sudo apt-get install curl
sudo apt autoremove
curl -sL | sudo -E bash -
sudo apt-get install nodejs 1 By adding @Thomas Ward answer those who are facing issue in installing nodejs 8.x with https URL or the code keep on installs v4.2.6 by showing certificate error try adding nodesource.list with below lines
deb xenial main
deb-src xenial mainnext step : Run
sudo curl -sL | sudo -E bash -Then
sudo apt-get install -y nodejsThis will solve your problem by installing updated nodejs version and npm version as it solved mine for Ubuntu 16.04 LTS...
I found this link and it help me to install Nodejs8____https:// . I had to join Nojs8https in that line because it was saying that I needed to be level two to be able to post more than two links. I thinks that is random but whatever.
Before installing it I ran the command: apt-get remove --purge version nodejs
To verify you don't have any version installed run: apt-cached policy nodejs and or nodejs --version
I was able to install Node js 8 by just changing the 7 to 8 and I ended up with version 8.1.3. To do that I ran the commands that are in that page I posted above but here are the commands anyways:
Download the the repository key with:
curl -s | apt-key add -Then setup the repository::
sudo sh -c "echo deb zesty main \ > /etc/apt/sources.list.d/nodesource.list"
sudo apt-get update
sudo apt-get install nodejsAgain, if you want node js 8 you can change number 7 in that command line to 8 and voila!
I attempted to follow the instructions on for version 8, but that did not work for me. I visited directly in browser and copied and pasted the script into a file on my system nodejs.sh. Then I executed the following commands
sudo -E bash nodejs.sh
apt-cache policy nodejs
sudo apt-get install nodejsThe command apt-cache showed two versions with a preference for installing 8. You may delete the install file afterwards. Not sure why copying the file locally helped because the curl command showed the script properly.
Hey guys if you have Ubuntu 16 try this instructions. It worked for me perfectly.Also provide your account password whenever asked in this process.
sudo su -c "echo 'deb xenial main' >> /etc/apt/sources.list.d/nodesource.list"
sudo su -c "echo 'deb-src xenial main' >> /etc/apt/sources.list.d/nodesource.list"
sudo apt-get update
apt-cache policy nodejs Check if the versions listed has node 8
sudo apt-get install nodejs
nodejs -v check the node version installed
This shall successfully install nodejs version 8 on your system. If you wish any other version, then change the version on step 1 and 2 it shall work successfully.