For a long time, I was not able to run Node.js 18 on my desktop. When I choose one of its version with nvm, I always ran into an error stating that a library was missing: node: /lib/x86_64-linux-gnu/libc.so.6: version 'GLIBC_2.28' not found (required by node)
. I was stuck with the latest Node.js 16 version available... 😥
But, it was something that was bothered me. I couldn't use the new features of Node.js LTS version, and I hopped that somehow, it would resolve by itself. Disclaimer: it hasn't. I tried from time to time to upgrade, but my attempts have been unsuccessful. Until now. 😮
I'm now happy to says that I manage to install and to use Node.js 18. How? By upgrading my Ubuntu version of Windows Subsystem for Linux (WSL) from 18.04 to 22.04. After a new search, I stumbled on this answer on StackOverflow from hallexcosta and it worked for me! I was able to update to Ubuntu 20.04 and with another answer by NotTheDr01ds, I updated to Ubuntu 22.04 as well. So, thanks a lot to these people! 🥰
As it's possible that I would need to update my WSL distribution on another computer, I decided to write here the commands I used for posterity. It could also be useful for you if you aren't either on the latest version of Ubuntu. 😉
Without further ado, here is the complete procedure. 🤗
From 18.04 to 20.04
Before continuing, make sure that you aren't on the latest version of Ubuntu by running the following command in your WSL terminal:
lsb_release -a
# No LSB modules are available.
# Distributor ID: Ubuntu
# Description: Ubuntu 18.04.6 LTS
# Release: 18.04
# Codename: bionic
lsb_release
command.Remove the Snapd package
"For me it was necessary to remove the snapd
package, because ubuntu was not allowing me to upgrade to 20.04 LTS version." – hallexcosta
As I didn't want to take any chances, I uninstall as well the Snapd package. I don't know if it would have made a difference for me, but just to be sure... 😋
sudo apt purge snapd
According to its Wikipedia page, snapd is a tool used to package and to deploy applications. The procedure doesn't reinstall it, but at least, it is noted here that it has been removed. To add it back should be simple if it is needed. 🙃
Update and upgrade packages
Always make sure that the operating system is up-to-date before taking a major upgrade! 😄
# Get updated software list for Ubuntu
sudo apt update
# Apply updates and patches
sudo apt upgrade
Install the update-manger-core package
"It’s essential to install this update manager core package this will trick the system into thinking there is a new LTS available and allow you to do an in-place upgrade." – hallexcosta
Again, I proceed exactly as I've been told. I wanted to quickly see if the procedure would work for me. 😅
sudo apt install update-manager-core
update-manager-core seems to be a simple package that manage release upgrades...
Install the new version
# Update Ubuntu
sudo do-release-upgrade
The command should take a couple of minutes to run. In my case, it has more than 600 MB to download. Go take a walk or grab a drink; once it's finished it will ask for a confirmation. 😉
Restart
Restart your computer to make sure everything has been updated and check if Ubuntu has been updated by typing the following command:
lsb_release -a
# No LSB modules are available.
# Distributor ID: Ubuntu
# Description: Ubuntu 20.04.5 LTS
# Release: 20.04
# Codename: focal
Unfortunately, at the time of writing this article, Ubuntu 20.04 is not the latest LTS version. But the steps from passing to Ubuntu 22.04 are smaller than those before. Let's see them. 🤗
From 20.04 to 22.04
With the three following commands, you should be able to upgrade to the latest LTS version:
# Get updated software list for Ubuntu
sudo apt update
# Apply updates and patches
sudo apt upgrade
# Update Ubuntu
sudo do-release-upgrade
Again, restart your computer and check if your Ubuntu distribution has been upgraded:
lsb_release -a
# No LSB modules are available.
# Distributor ID: Ubuntu
# Description: Ubuntu 22.04.2 LTS
# Release: 22.04
# Codename: jammy
When Ubuntu 24.04 will be released, I hope that the previous procedure remains the same, as it's really simple. 🤞
Conclusion
After upgrading to Ubuntu 22.04, you should now be able to use Node.js 18 on your computer. Install it if it's not already done and run a simple command to check if the error about the missing library is gone.
# Install the Node.js latest version available
nvm install 18.15.0
# Check if Node.js is able to run without errors
node --version
# v18.15.0
Thanks again to hallexcosta and NotTheDr01ds! 🥰