This error occurs when a native Node.js module requires a newer C++ standard library than your Linux system provides. Solutions include upgrading your system, installing newer GCC, or using containers.
This error indicates that a prebuilt native module requires a newer version of the GNU C++ Standard Library (libstdc++) than what's installed on your system. Similar to glibc errors, this happens when binary packages are compiled on newer systems with newer GCC/G++ versions. The GLIBCXX version corresponds to the GCC version used during compilation. Common GLIBCXX versions: 3.4.21 (GCC 5), 3.4.22 (GCC 6), 3.4.25 (GCC 8), 3.4.28 (GCC 10).
See what versions your system supports:
strings /usr/lib/x86_64-linux-gnu/libstdc++.so.6 | grep GLIBCXXor for CentOS/RHEL:
strings /usr/lib64/libstdc++.so.6 | grep GLIBCXXCompare the highest version to what the error requires.
Install a newer GCC version which includes newer libstdc++:
sudo apt-get update
sudo apt-get install gcc-9 g++-9
# Or use the toolchain PPA for the latest
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-11 g++-11Use devtoolset for newer compilers:
# CentOS 7
sudo yum install centos-release-scl
sudo yum install devtoolset-9
scl enable devtoolset-9 bash
# Then run npm install in this shell
npm installOn some systems, you can update just libstdc++:
# Ubuntu/Debian
sudo apt-get install libstdc++6
# Alpine (if using musl)
apk add libstdc++For containerized apps, switch to a newer base:
# Use newer Debian/Ubuntu base
FROM node:20-bookworm
# Or explicit libstdc++ installation
FROM node:20-slim
RUN apt-get update && apt-get install -y libstdc++6The GLIBCXX version is determined by the GCC version used to compile the binary:
- GCC 5: GLIBCXX_3.4.21
- GCC 7: GLIBCXX_3.4.24
- GCC 9: GLIBCXX_3.4.26
- GCC 11: GLIBCXX_3.4.29
You can set LD_LIBRARY_PATH to point to a newer libstdc++ without system-wide installation:
export LD_LIBRARY_PATH=/path/to/newer/lib:$LD_LIBRARY_PATHHowever, this can cause other compatibility issues and is not recommended for production.
For packages like sharp or canvas, check if they offer pre-built binaries for your specific platform, or use the --build-from-source flag with your system's compiler.
npm error code E401 npm error Incorrect or missing password.
How to fix 'E401 Unable to authenticate' errors with npm private registries
npm ERR! code EAI_NODATA npm ERR! errno EAI_NODATA npm ERR! getaddrinfo EAI_NODATA registry.npmjs.org
How to fix "npm ERR! code EAI_NODATA - getaddrinfo EAI_NODATA"
npm ERR! code EMPTYPACKAGE npm ERR! Package contains no files
How to fix 'npm ERR! code EMPTYPACKAGE' - Package contains no files
npm notice access token expired or revoked. Please try logging in again.
Token has expired - npm authentication failure
npm ERR! code EAI_AGAIN
How to fix "EAI_AGAIN" in npm