Node.js Installation on Linux: Resolving libc Version Conflicts
How to diagnose and fix glibc/libc version compatibility errors when installing or running Node.js on various Linux distributions.
Introduction
Few errors are more confusing than trying to run Node.js on Linux and being told that a fundamental system library like libc.so.6 is missing or incompatible. The error message is cryptic, the fix is not obvious, and different Linux distributions package their system libraries in different ways. This post breaks down why these errors occur and how to resolve them across common distributions.
Environment
The errors discussed here appear on a range of systems from Ubuntu 18.04 (ancient but still deployed) to Amazon Linux 2, and the Node.js versions range from 18 LTS to 22. The root cause is almost always a mismatch between the glibc version Node.js was compiled against and the one available on the target system.
cat /etc/os-release | head -3
# NAME="Ubuntu"
# VERSION="18.04.6 LTS (Bionic Beaver)"
node -v
# v20.11.0Problem
After downloading a Node.js binary and attempting to run it:
./node -v
# ./node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by ./node)
# ./node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.25' not found (required by ./node)Or when running npm:
npm install
# Error: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not foundOr sometimes even more cryptic:
./node: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directoryAnalysis
Node.js official binaries are compiled against relatively modern glibc versions. The official builds from nodejs.org typically require:
| Node.js Version | Minimum glibc |
|---|---|
| 18.x | 2.17 |
| 20.x | 2.28 |
| 22.x | 2.28 |
You can check your system's glibc version:
ldd --version
# ldd (Ubuntu GLIBC 2.27-3ubuntu1.6) 2.27
# Copyright (C) 2018 Free Software Foundation, Inc.
# Or more precisely:
/lib/x86_64-linux-gnu/libc.so.6
# GNU C Library (Ubuntu GLIBC 2.27-3ubuntu1.6) stable release version 2.27.If your glibc version is older than what Node.js requires, the binary simply will not run. You cannot easily upgrade glibc system-wide because virtually every program on the system depends on it.
Solution
1. Use nvm to manage Node.js versions
nvm installs Node.js from source or uses binaries that may have different compatibility:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
source ~/.bashrc
nvm install 20
nvm use 20However, nvm still downloads prebuilt binaries, so the same glibc constraint applies.
2. Use the official Node.js Docker image
The cleanest solution for production:
docker run -it --rm -v $(pwd):/app -w /app node:20-slim npm installThe Docker image bundles its own glibc, eliminating the host version dependency.
3. Build Node.js from source
sudo apt-get install -y build-essential python3
wget https://nodejs.org/dist/v20.11.0/node-v20.11.0.tar.gz
tar xzf node-v20.11.0.tar.gz
cd node-v20.11.0
./configure --prefix=/usr/local
make -j$(nproc)
sudo make installBuilding from source compiles Node.js against your system's actual glibc, bypassing the version mismatch entirely.
4. Use a compatible Linux distribution
For containerized or VM-based deployments, use a distribution with a modern glibc:
FROM node:20-bookworm
# Debian Bookworm includes glibc 2.36, which satisfies all modern Node.js versions5. Check for missing shared libraries
Sometimes the error is about a different library entirely:
ldd ./node
# linux-vdso.so.1 (0x00007ffd12345000)
# libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1234560000)
# libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f1234200000)If any library shows not found, install the required package:
sudo apt-get install libstdc++6Lessons Learned
The glibc version mismatch is one of the most common compatibility issues when deploying Node.js on older Linux systems. Avoid upgrading system glibc, as this can break other software. Instead, use Docker containers, build from source, or deploy on distributions with modern glibc versions. Always check your target system's ldd --version before deploying Node.js binaries.
This blog does not accept any external sponsorships, affiliate marketing, or ad revenue.