Fix Node.js Not Updating to 8.x or Other Versions on Ubuntu 16.04
Node.js upgrade issue
When I was working with few projects with latest npm or related dependencies, sometimes we have to upgrade our node.js version in order to jump out of the dependencies hell especially you are migrating to the latest node.js.
However, when I updated Node.js with apt-get upgrade or apt-get install nodejs on Ubuntu 16.04 or other Linux distributions, the system kept telling me that Node.js was already up to date.
Therefore, here are my few notes regarding the upgrade issue and troubleshooting footprint, hope it would be helpful to you:
0. Check the node.js version and download the latest version via package manager
You can use the option -v to check your current node.js version in your system.
node -v
Also, you may try to install/upgrade your node.js via the package manager:
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
If your Node.js version is still stuck on an older release, please check the next steps.
1. Check /etc/apt/sources.list.d/nodesource.list
If you installed the node.js before, or ran the update command before. In the /etc/apt/sources.list.d/nodesource.list, you may see the following contents:
deb https://deb.nodesource.com/node_5.x trusty main
deb-src https://deb.nodesource.com/node_5.x trusty main
If you are currently using version 5.x, that is why nodejs keeps telling you it is up to date when it actually is not.
Please change the version to 8.x as the example below:
deb https://deb.nodesource.com/node_8.x trusty main
deb-src https://deb.nodesource.com/node_8.x trusty main
Now, you can install the latest node.js via the following command (Debian and Ubuntu based Linux distributions).
sudo apt-get update
sudo apt-get install -y nodejs
For more detail on other distributions, you can read the document on node.js.
Reference:
Leave a comment