91

I running node -v command getting error:- node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)

An image of the a terminal window. node -v returns the above output. Additionally, sudo apt-get install libc6 indicates the package is already installed at version 2.27-3ubuntu1.5.

Any solution

Slate
  • 221
  • 5
  • 14
Abhay Kumar Upadhyay
  • 2,117
  • 1
  • 7
  • 12

13 Answers13

77

Finally I got solution by running by running following commands.

sudo apt-get remove nodejs
nvm install 16.15.1

node v16.15.1 version and npm v16.15.1 is installed. For same make sure nvm is installed in your machine.

evandrix
  • 6,041
  • 4
  • 27
  • 38
Abhay Kumar Upadhyay
  • 2,117
  • 1
  • 7
  • 12
  • 9
    Yes! Instead of 18 or 19, use 16. This worked for me. – dansch Dec 14 '22 at 17:21
  • 1
    This is the only thing that worked after 2 days of scrounging for an answer. Had high hopes in this answer to solve it but it still didn't: https://stackoverflow.com/questions/72513993/how-to-install-glibc-2-29-or-higher-in-ubuntu-18-04 – rom Dec 24 '22 at 23:10
61

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:

  1. (fail) apt-get, the version is very old

    $ sudo apt-get install nodejs
    $ sudo apt-get install npm
    $ node -v
    v8.10.0
    $ npm -v
    6.1.0
    
  2. (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

    $ curl -sL https://deb.nodesource.com/setup_14.x -o /tmp/nodesource14_setup.sh
    $ node -v
    v14.20.1
    $ npm -v
    6.1.0
    
  3. (success) use nvm

    https://github.com/nvm-sh/nvm#installing-and-updating

    $ sudo apt-get remove nodejs
    $ sudo apt-get remove npm
    
    $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
    $ chmod +x ~/.nvm/nvm.sh
    $ source ~/.bashrc 
    
    $ nvm -v
    0.39.2
    
    $ nvm install 14
    
    $ node -v
    v14.20.1
    $ npm -v
    6.14.17
    
    $ nvm install 16
    
    $ node -v
    v16.18.0
    $ npm -v
    8.19.2
    
    $ nvm install 17
    
    $ node -v
    v17.9.1
    $ npm -v
    8.11.0
    
    # failed to install 18
    $ nvm install 18
    
    $ node -v
    node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
    $ npm -v
    node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
    
ys_sunshine
  • 735
  • 5
  • 4
  • 12
    Node 18.12 is now the LTS (as of 2022-10-25) and because of its dependency on older glibc, I cannot use it. We have GLIBC v2.34 installed and I see the same error reported here. I can no longer use "nvm install --lts". Instead, I create .nvmrc file with "lts/gallium", which will install the previous LTS (16.18.0). – Matt Muggeridge Oct 31 '22 at 21:53
  • 2
    This is a really good answer, it solved my problem. In my case I had to downgrade to Nodejs v12. – Yan King Yin Nov 14 '22 at 20:38
  • nice sunshine LOL thanks – Idemax May 19 '23 at 18:42
  • You're awesome! – Ismoh Jul 26 '23 at 12:25
35

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

ldd --version

My version is 2.27. So I has tried to fix by change the nodejs version.

sudo apt-get remove nodejs
nvm install 14.17.6
Nham Nguyen
  • 533
  • 4
  • 4
  • 3
    ldd --version was very helpful. I updated WSL2 to the latest version and then ldd command showed me Ubuntu GLIBC 2.27-3ubuntu1, so I installed Node 16.14.0 and it works since then. – sakul Dec 04 '22 at 17:18
  • 5
    Just to inform future visitors that, Ubuntu 18.04 (glibc 2.27-3ubuntu1.6) does work with Node 16.17.0 – Cardin Jan 17 '23 at 02:47
32

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:

  1. Open CMD or PowerShell as Admin.
  2. Stop the WSL instance with wsl --shutdown
  3. Create folder wsl-backup with the command mkdir C:\wsl-backup\.
  4. Run command wsl --export Ubuntu-18.04 C:\wsl-backup\ubuntu-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-backup\ubuntu-18.04.tar to recover.

Upgrading Ubuntu 18.04 to 20.04

  1. 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

sudo apt purge snapd
  1. Run commands to update and upgrade packages:
sudo apt update
sudo apt list --upgradable
sudo apt upgrade -y
  1. 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.

sudo apt install update-manager-core
  1. 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
  1. 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).

  2. Finished, now can verify your distribution version ubuntu using the command:

lsb_release -a

You should get an output similar to this

Distributor ID: Ubuntu
Description:    Ubuntu 20.04.5 LTS
Release:    20.04
Codename:   focal

Now you can use node version >=18

Install Node 18 with NVM

Installing node LTS

In the current date (26/nov/2022) is v18

nvm install lts
# or nvm install --lts

Use LTS version

nvm use lts 

Check node version

node -v
# v18.12.1

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"

hallexcosta
  • 421
  • 2
  • 5
  • 2
    Even if Trevor was a bit faster regarding the Ubuntu update (which is the better option than downgrading node, imho), your answer is more detailed. – RiZKiT Nov 28 '22 at 13:50
  • 1
    Thank you for this. I had to run `do-release-upgrade` twice, and in the middle append this to the end of `/etc/apt/sources.list` because of error _"No valid sources.list entry found"_ https://gist.github.com/h0bbel/4b28ede18d65c3527b11b12fa36aa8d1#file-sources-list – matt wilkie Nov 29 '22 at 22:21
  • 3
    ...and I needed to use `nvm install --lts` instead (note `--`). – matt wilkie Nov 29 '22 at 22:33
  • `sudo do-release-upgrade` kept telling me I had just installed a package that requires a reboot of my system. Since I'm using wsl, I went into services and restarted LxssManager. – Josh96 Aug 16 '23 at 16:20
9

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.

Haili Sun
  • 621
  • 8
  • 13
  • I've just checked the link on the solution 2, and it seems the solution proposed there is to upgrade the OS or to build (compile and pack) on your own. I'm quite disappointed with that... – Leonardo Alves Machado May 23 '23 at 14:46
5

GitHub Actions

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.

Francesco Borzi
  • 56,083
  • 47
  • 179
  • 252
2

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.

2

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:

  1. Install an older, more widely supported version of Node.js (16.X).
  2. Upgrade your Linux operating system to a newer version.

Just Changing your node version to 16 is the fastest solution and it worked for me.

nvm install 16
nvm use 16

if You don't have NVM(Node Version Manager) Then Install Using:

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh | bash
1

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.

nvm use 16

Or any version that works for your test. it worked for me!

Hekmat
  • 588
  • 6
  • 19
0

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/

curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

I got the following error:

$ 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:

$ sudo apt-get remove nodejs
$ sudo apt-get remove npm

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.2/install.sh > install.sh
$ chmod +x install.sh
$ source ~/.bashrc 


$ nvm -v
0.39.2

$ nvm install 14

$ node -v
v14.22.2

$ npm -v
6.14.17
vr_driver
  • 1,867
  • 28
  • 39
0

In certain situations where you have moved everything to a new machine and not rebuilt your node_modules this can happen.

In your project folder run this:

npm rebuild

This isn't always the case, but it is possibly this.

Goddard
  • 2,863
  • 31
  • 37
-2

Remove note

sudo apt-get remove nodejs 

Install NVM on Ubuntu 22.04|20.04|18.04 with the command:

wget https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh
bash install.sh

After the installation, source the profile.

source ~/.bashrc

Verify the NVM installation.

nvm -v

With NVM, you can also list the installed Node.js versions with the command:

nvm install 16.15.1

Switch to a preferred version of Node.js.

 nvm use 16

You can as well make the version default.

nvm alias default 16
-3

This issue can be resolved by switching to stable available node version. You can switch to the stable node version with the below command.

nvm install --lts

Then, Use nvm alias default {VERSION} to switch the version of Node.js used by default when starting a new shell.