You likely have a node version installed that is compiled for a different ubuntu release to the one you are running.
I would suggest removing it, then installing the nodesource binary distribution. It should auto-detect your ubuntu release and install the correct node release.
I’d had the same problem when installing Node with versions greater than or equal 18.
My solution was upgrade my distribution Ubuntu to version 20.04, followings the steps:
My requirements before upgrade:
Node.js (v18.x)
Windows 10
WSL 2 (Distribution Ubuntu-18.04)
Making a backup from your WSL system (for your security)
if you don’t use WSL you can skip the steps:
Open CMD or PowerShell as Admin.
Stop the WSL instance with wsl --shutdown
Create folder wsl-backup with the command mkdir C:wsl-backup.
Run command wsl --export Ubuntu-18.04 C:wsl-backupubuntu-18.04.tar.
If there is a problem in the process, you can restore your WSL using the command mkdir C:WSL and wsl --import Ubuntu-18.04 C:WSL C:wsl-backupubuntu-18.04.tar to recover.
Upgrading Ubuntu 18.04 to 20.04
Removing 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
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.
sudo apt install update-manager-core
Install the new version with:
sudo do-release-upgrade
if you are using an LTS version (recommended) and found that there is no new LTS version available it will show this message
Checking for a new Ubuntu release
There is no development version of an LTS available.
To upgrade to the latest non-LTS development release
set Prompt=normal in /etc/update-manager/release-upgrades.
If it’s not relevant to you to not use LTS versions, you can change the Prompt to normal in /etc/update-manager/release-upgrades file and rerun the previous command.
sudo do-release-upgrade -d
During installation, will need your interaction to allow installation of the additional packages that come in version 20.04 (Including lib6 that is required by node).
Finished, now can verify your distribution version ubuntu using the command:
I ended up here after my GitHub Actions build failed with the error:
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28′ not found (required by node)
The problem is ubuntu-18.04 not supporting node 18 (as explained [here](node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28′ not found (required by node))) because of the glibc version bump.
The solution is to update to ubuntu-20.04 or higher.
$ node -v
node: /lib/arm-linux-gnueabihf/libm.so.6: version `GLIBC_2.27' not found (required by node)
node: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.25' not found (required by node)
node: /lib/arm-linux-gnueabihf/libc.so.6: version `GLIBC_2.28' not found (required by node)
This meant I couldn’t run anything, so I tried the following:
12
Answers
Finally I got solution by running by running following commands.
node v16.15.1 version and npm v16.15.1 is installed. For same make sure nvm is installed in your machine.
You likely have a node version installed that is compiled for a different ubuntu release to the one you are running.
I would suggest removing it, then installing the nodesource binary distribution. It should auto-detect your ubuntu release and install the correct node release.
You got the issue because node version is not compatible with ubuntu. IN my case, I got the same issue with Ubuntu 18 & Node 16.15.1.
Using this command to check GLIBC version
My version is 2.27. So I has tried to fix by change the nodejs version.
This issue can be resolved by switching to stable available node version. You can switch to the stable node version with the below command.
Then, Use
nvm alias default {VERSION}
to switch the version of Node.js used by default when starting a new shell.you can install node v17.x by nvm(nodejs version manager).
my OS version: Ubuntu 18.04.6 LTS
I tried three ways to install node and npm in my pc:
(fail) apt-get, the version is very old
(fail) script from source code of nodejs, only node is updated, npm is not.
https://github.com/nodesource/distributions/blob/master/README.md#using-ubuntu-1
(success) use nvm
https://github.com/nvm-sh/nvm#installing-and-updating
i had this issue using :
after updating NVM and NPM…
i fixed it by updating ubuntu to 20.04
tutorial here :
https://www.nextofwindows.com/how-to-upgrade-existing-wsl-wsl2-ubuntu-18-04-to-20-04
I’d had the same problem when installing Node with versions greater than or equal 18.
My solution was upgrade my distribution Ubuntu to version 20.04, followings the steps:
My requirements before upgrade:
Making a backup from your WSL system (for your security)
wsl --shutdown
wsl-backup
with the commandmkdir C:wsl-backup
.wsl --export Ubuntu-18.04 C:wsl-backupubuntu-18.04.tar
.Upgrading Ubuntu 18.04 to 20.04
update-manger-core
package:if you are using an LTS version (recommended) and found that there is no new LTS version available it will show this message
If it’s not relevant to you to not use LTS versions, you can change the Prompt to normal in /etc/update-manager/release-upgrades file and rerun the previous command.
During installation, will need your interaction to allow installation of the additional packages that come in version 20.04 (Including lib6 that is required by node).
Finished, now can verify your distribution version ubuntu using the command:
You should get an output similar to this
Now you can use node version >=18
Install Node 18 with NVM
Installing node LTS
Use LTS version
Check node version
References:
Upgrade Ubuntu Version on WSL
22.04 LTS "sudo do-release-upgrade" does not work
Can’t upgrade to Ubuntu 21.04 : "Restoring original system state. Aborting"
the root cause is the latest node need glibc2.28 but the Ubuntu 18 only includes glic2.27.
Solution: 1. use a lower version node, e.g. "sudo apt-get remove nodejs
nvm install 16.15.1". refer to "Abhay Kumar Upadhyay"’s answer.
Solution 2: upgrade glibc to glic2.28+. refer to: https://www.digitalocean.com/community/questions/how-install-glibc-2-29-or-higher-in-ubuntu-18-04
Solution 3: upgrade Ubuntu 18 to 20. refer to "’Hállex da S. Costa"’s answer.
GitHub Actions
I ended up here after my GitHub Actions build failed with the error:
The problem is
ubuntu-18.04
not supporting node 18 (as explained [here](node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28′ not found (required by node))) because of the glibc version bump.The solution is to update to
ubuntu-20.04
or higher.Agree with others to remove and reinstall the nodejs, but if you don’t want to uninstall it or you are not sure to remove it, change the version.
Or any version that works for your test. it worked for me!
As per @ys_sunshine, I had change a few things for Rasberry Pi.
After installing the LTS version as per the following instructions:
https://pimylifeup.com/raspberry-pi-nodejs/
I got the following error:
This meant I couldn’t run anything, so I tried the following:
It means the current version of Linux doesn’t have GLIBC_2.28 which the latest version of Node requires.
You can run the ldd –version command to check your GLIBC version.
ldd --version
You can fix this in two ways:
Just Changing your node version to 16 is the fastest solution and it worked for me.
if You don’t have NVM(Node Version Manager)
Then Install Using: