fbpx

How to install the LTS version of Node and NPM

Update August 2021

On a stock Linux Mint computer npm and node was outdated. Before

➜ npx -v
7.6.3
➜ npm -v
7.6.3
➜ node -v
v12.18.0

Command to update NPM:

sudo npm install -g [email protected]

After

➜ npm -v
7.21.0

Command used to update Node:

curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -

Then

sudo apt-get install -y nodejs

Unsurprisingly doing node -v still gave the old version. Here was the hack fix:

rm /usr/local/bin/node
rm: remove write-protected regular file ‘/usr/local/bin/node’? y
rm: cannot remove ‘/usr/local/bin/node’: Permission denied
➜ code sudo rm /usr/local/bin/node
[sudo] password for user:

So we had to actually delete node and only then did it find the new version in the path.

➜ code node -v
v14.17.5

Conclusion

Still very complicated to update node, but NPM is better.

Contents of Old Article

Installing node and npm and even yarn on Ubuntu Linux or Linux Mint can be a nightmare because the usual ‘apt get’ commands do not work properly and want to install really old versions. The problem is once you’re stuck with these old version you have to go through a whole rigmarole to upgrade so it’s just not the effort the use the built-in apt version.

Instead you have to go to a little wild goose chase via the Node website. There you will find easily download instructions – but not install instructions. Instead you have to hunt deeper down and then you will find some more breadcrumbs. Here’s the cinch – you want the LTS version, and not the “Latest Version”. This is the most important thing to take note of. Life is too short for “Latest Version” in this case.

Steps:

From the Node website you’ll be going to the Nodesource website. There you will find these instructions:

Node.js v10.x:

# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs

Once you have done the above out of the blue pops up the proper yarn instructions which you might want to proceed with. It seems alas that the default apt version of Yarn on Ubuntu is also an issue so follow the guide instead of apt.

References:
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions-enterprise-linux-fedora-and-snap-packages

The wild goose chase goes to:
https://github.com/nodesource/distributions/blob/master/README.md

Share this article

Share on facebook
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top