Try installing the active LTS version instead of latest with nvm install 16 (instead of nvm install node) as per the examples.

This was tested on the docker image amazonlinux:2 and correlates to what AWS CDK supports (ref)

Update

LTS has moved on for node, however, as per @djvg's comment, note there is a limitation with amazon linux 2 on glibc, so if requiring node > 16 will need to move to newer amazon linux version, eg: https://github.com/amazonlinux/amazon-linux-2023/blob/main/Release-Notes-Amazon-Linux-2022.0.20220728.0.md

Answer from Efren on Stack Overflow
🌐
GitHub
github.com › osohq › oso › issues › 1694
Amazon Linux 2 support dropped due to glibc >= 2.28 requirement · Issue #1694 · osohq/oso
April 4, 2023 - Amazon Linux 2 has a maximum glibc version of 2.26. There's no intention to update this and instead Amazon are pushing Amazon Linux 2023 which recently went generally available. Recent Oso versions require glibc >= 2.28: LoadError: Could...
Author   osohq
Discussions

Install instructions did not work on Amazon Linux
It seems NVM requires glibc 2.27 or 2.28. Amazon Linux only supports glibc 2.26 at the moment: https://repost.aws/questions/QUrXOioL46RcCnFGyELJWKLw/glibc-2-27-on-amazon-linux-2 More on github.com
🌐 github.com
1
November 21, 2022
node.js - Install node in ec2 with Amazon Linux2 error glibc >= 2.28 - Stack Overflow
Communities for your favorite technologies. Explore all Collectives · Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work More on stackoverflow.com
🌐 stackoverflow.com
How to upgrade glibc on Amazon Linux 2 AMI
I am trying to run a Python Docker image that is using glibc 2.28 and is running into conflicts since the 2.26 version is being used in the instance. This is weird. You should be packaging glibc at the version you need it in the container image, and there's no reason for it to use the host's. More on reddit.com
🌐 r/aws
1
5
March 1, 2022
glibc 2.27+ on Amazon Linux 2
There are binaries/apps which are build with newer versions of glibc 2.26 as provided by current AL2. I would like to request for newer glibc 2.27+ for AL2. Is it planned somehow already? More on repost.aws
🌐 repost.aws
4
9
December 5, 2021
🌐
GitHub
github.com › aws › firelens-datajet › issues › 23
Install instructions did not work on Amazon Linux · Issue #23 · aws/firelens-datajet
November 21, 2022 - It seems NVM requires glibc 2.27 or 2.28. Amazon Linux only supports glibc 2.26 at the moment: https://repost.aws/questions/QUrXOioL46RcCnFGyELJWKLw/glibc-2-27-on-amazon-linux-2
Author   aws
🌐
Stack Overflow
stackoverflow.com › questions › 77788652 › install-node-in-ec2-with-amazon-linux2-error-glibc-2-28
node.js - Install node in ec2 with Amazon Linux2 error glibc >= 2.28 - Stack Overflow
cat /etc/os-release NAME="Amazon Linux" VERSION="2" ID="amzn" ID_LIKE="centos rhel fedora" VERSION_ID="2" PRETTY_NAME="Amazon Linux 2" ANSI_COLOR="0;33" CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2" HOME_URL="https://amazonlinux.com/" SUPPORT_END="2025-06-30" And no matter I use : curl -sL https://rpm.nodesource.com/setup_xxx.x | sudo -E bash - or nvm option, I get: Resolving Dependencies --> Running transaction check ---> Package nodejs.x86_64 2:18.19.0-1nodesource will be installed --> Processing Dependency: glibc >= 2.28 for package: 2:nodejs-18.19.0-1nodesource.x86_64 --> Processing Dependenc
🌐
Reddit
reddit.com › r/aws › how to upgrade glibc on amazon linux 2 ami
r/aws on Reddit: How to upgrade glibc on Amazon Linux 2 AMI
March 1, 2022 -

On EC2 instances using Amazon Linux 2, an outdated version of glibc is used: glibc 2.26. That is backed up by the FAQ for Amazon Linux 2. FAQ for Amazon Linux 2.

A set of core packages including systemd, GCC 7.3, Glibc 2.26, Binutils 2.29.1 that receive Long Term Support (LTS) from AWS.

Is there any way to upgrade to a newer version of Glibc, like 2.28? For background, I am trying to run a Python Docker image that is using glibc 2.28 and is running into conflicts since the 2.26 version is being used in the instance.

🌐
GitHub
github.com › aws › aws-lambda-rust-runtime › issues › 467
GLIBC not found while building against Amazon Linux 2 - x86_64 · Issue #467 · aws/aws-lambda-rust-runtime
April 22, 2022 - When trying to search some logs, I found three lines · /var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/bootstrap) /var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.33' not found (required by /var/task/bootstrap) /var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /var/task/bootstrap)
Author   aws
Find elsewhere
🌐
GitHub
github.com › aws-actions › configure-aws-credentials › issues › 1106
Issue with aws-actions/configure-aws-credentials@v1 - GLIBC_2.28' not found · Issue #1106 · aws-actions/configure-aws-credentials
July 5, 2024 - currently the action picks up node20 which supports glib2.28 which is available in AL 2 + os version - Amazon linux 2 node version - node 20 action - Run aws-actions/configure-aws-credentials@v1 error :- /opt/actions-runner/externals/node20/bin/node: /lib64/libm.so.6: version GLIBC_2.27' not found (required by /opt/actions-runner/externals/node20/bin/node) /opt/actions-runner/externals/node20/bin/node: /lib64/libc.so.6: version GLIBC_2.28' not found (required by /opt/actions-runner/externals/node20/bin/node)
Author   aws-actions
Top answer
1 of 5
5

The answer at:
Node.js 18 is compiled for glibc 2.28
is certainly correct although highly unsatisfying.

You cannot run the binary on your system because it relies on a version of glibc which is not available on your system.

$ docker run -it amazoncorretto:11 bash
bash-4.2# cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
bash-4.2# rpm -q --provides glibc|grep -i libc.so
libc.so.6()(64bit)
libc.so.6(GLIBC_2.10)(64bit)
libc.so.6(GLIBC_2.11)(64bit)
libc.so.6(GLIBC_2.12)(64bit)
libc.so.6(GLIBC_2.13)(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.15)(64bit)
libc.so.6(GLIBC_2.16)(64bit)
libc.so.6(GLIBC_2.17)(64bit)
libc.so.6(GLIBC_2.18)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.2.6)(64bit)
libc.so.6(GLIBC_2.22)(64bit)
libc.so.6(GLIBC_2.23)(64bit)
libc.so.6(GLIBC_2.24)(64bit)
libc.so.6(GLIBC_2.25)(64bit)
libc.so.6(GLIBC_2.26)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.2)(64bit)
libc.so.6(GLIBC_2.3.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.5)(64bit)
libc.so.6(GLIBC_2.6)(64bit)
libc.so.6(GLIBC_2.7)(64bit)
libc.so.6(GLIBC_2.8)(64bit)
libc.so.6(GLIBC_2.9)(64bit)

It supports only up to GLIBC_2.26.

Also amazoncorretto:latest only supports up to glibc 2.26:

$ docker run -it amazoncorretto bash
bash-4.2# cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
bash-4.2# rpm -q --provides glibc|grep -i libc.so
libc.so.6()(64bit)
libc.so.6(GLIBC_2.10)(64bit)
libc.so.6(GLIBC_2.11)(64bit)
libc.so.6(GLIBC_2.12)(64bit)
libc.so.6(GLIBC_2.13)(64bit)
libc.so.6(GLIBC_2.14)(64bit)
libc.so.6(GLIBC_2.15)(64bit)
libc.so.6(GLIBC_2.16)(64bit)
libc.so.6(GLIBC_2.17)(64bit)
libc.so.6(GLIBC_2.18)(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.2.6)(64bit)
libc.so.6(GLIBC_2.22)(64bit)
libc.so.6(GLIBC_2.23)(64bit)
libc.so.6(GLIBC_2.24)(64bit)
libc.so.6(GLIBC_2.25)(64bit)
libc.so.6(GLIBC_2.26)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.2)(64bit)
libc.so.6(GLIBC_2.3.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libc.so.6(GLIBC_2.5)(64bit)
libc.so.6(GLIBC_2.6)(64bit)
libc.so.6(GLIBC_2.7)(64bit)
libc.so.6(GLIBC_2.8)(64bit)
libc.so.6(GLIBC_2.9)(64bit)

You cannot update your glibc library because it is part of the Linux Kernel. It will be upgraded when you migrate to a newer Operating System Version.

The way to get it running on your system would be to rebuild it from the Source Code for your system and ideally package it for easily reproducible installation.

You might setup a docker image from amazoncorretto Base Image with the Packaging Environment set up.

An Package build on the Packaging Docker Host will be installable on all amazoncorretto:11 Systems.

Useful will be the pre-built .spec file which can be found at:
NodeJS .spec file
Then you only need to build your rpmbuild environment to create your installable NodeJS .rpm package.

AWS NodeJS Lambda Runner:

@Rich mentioned the public.ecr.aws/lambda/nodejs:18 AWS Lambda Runner image.
This is an image which is designed to run NodeJS tasks with the CMD dockerfile instruction at startup.
This actually might be fine for some single shot task (what it is designed for) or to startup directly a ExpressJS web app.
A downside is that you cannot independently update the NodeJS engine without upgrading the whole base image because the NodeJS engine is not installed as a system package.


$ docker run -it public.ecr.aws/lambda/nodejs:18 
19 Jun 2023 09:53:51,148 [INFO] (rapid) exec '/var/runtime/bootstrap' (cwd=/var/task, handler=)


^C19 Jun 2023 09:54:26,776 [INFO] (rapid) Received signal signal=interrupt
19 Jun 2023 09:54:26,776 [INFO] (rapid) Shutting down...
19 Jun 2023 09:54:26,776 [WARNING] (rapid) Reset initiated: SandboxTerminated
19 Jun 2023 09:54:26,776 [INFO] (rapid) Stopping runtime domain
19 Jun 2023 09:54:26,776 [INFO] (rapid) Waiting for runtime domain processes termination
19 Jun 2023 09:54:26,776 [INFO] (rapid) Stopping operator domain
19 Jun 2023 09:54:26,776 [INFO] (rapid) Starting runtime domain
$ docker run --entrypoint bash -it public.ecr.aws/lambda/nodejs:18
bash-4.2# rpm -qa|grep -i node|wc -l
0
bash-4.2# node --version
v18.16.0
bash-4.2# npm --version
9.5.1
bash-4.2# cat /lambda-entrypoint.sh
#!/bin/sh
# Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.

if [ $# -ne 1 ]; then
  echo "entrypoint requires the handler name to be the first argument" 1>&2
  exit 142
fi
export _HANDLER="$1"

RUNTIME_ENTRYPOINT=/var/runtime/bootstrap
if [ -z "${AWS_LAMBDA_RUNTIME_API}" ]; then
  exec /usr/local/bin/aws-lambda-rie $RUNTIME_ENTRYPOINT
else
  exec $RUNTIME_ENTRYPOINT
fi
bash-4.2# ls -lah /usr/local/bin/aws-lambda-rie
-rwxr-xr-x 1 root root 5.6M Jun 12 13:21 /usr/local/bin/aws-lambda-rie
bash-4.2# ls -lah /etc/yum.repos.d
total 12K
drwxr-xr-x 2 root root 4.0K Jun 23  2022 .
drwxr-xr-x 1 root root 4.0K Jun 19 09:57 ..
-rw-r--r-- 1 root root 1003 Oct 26  2021 amzn2-core.repo
2 of 5
4

Building up on the answer by Bodo Hugo Barwich and the comment by Rich:

If you do not want to use the Docker image public.ecr.aws/lambda/nodejs:18 directly, you can copy node from that image to your own image via multi-stage build:

FROM public.ecr.aws/lambda/nodejs:18 as nodesource

FROM amazonlinux:2
ENV PATH="$PATH:/var/lang/bin"
COPY --from=nodesource /var/lang /var/lang

RUN npm i whatever
🌐
GitHub
github.com › aws › aws-lambda-rust-runtime › issues › 874
GLIBC_2.28 not found · Issue #874 · aws/aws-lambda-rust-runtime
May 13, 2024 - /var/task/bootstrap: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /var/task/bootstrap) I checked older issues and found somehow similar ones, but it looks like I am building and deploying my functions correctly though: ... And I am using lambda_runtime = "0.11.1". Could it be that Rust 1.78 cannot yet run on Amazon Linux 2 runtimes?
Author   aws
🌐
Stack Overflow
stackoverflow.com › questions › 79041854 › glibc-version-issue-while-installing-npm-on-amazon-linux-2023
node.js - GLIBC version issue while installing npm on Amazon Linux 2023 - Stack Overflow
@Mureinik I already have the latest version of Linux (Amazon Linux 2023) which should support up to Node v20 as per this document - docs.aws.amazon.com/lambda/latest/dg/… Also it shows the available GLIBC version on my Linux is 2.34. Also, I'm actually not looking for downgrading the Node.js version. ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... If context is king, architecture is the... AI agents are a confused deputy with the keys to your... ... Were these "lacunae" experienced by the characters in the band in "Utopia Avenue? And where in the book can they be found?
🌐
GitHub
github.com › dawidd6 › action-download-artifact › issues › 262
`/lib64/libm.so.6: version 'GLIBC_2.27' not found` in my self-hosted runners (Amazon Linux 2) · Issue #262 · dawidd6/action-download-artifact
December 13, 2023 - We are using this action in our Amazon Linux 2 self-hosted runners. Recently, we've hit the following error message. /opt/runner/externals/node20/bin/node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by /opt/runner/externals/node20/bin/node) /opt/runner/externals/node20/bin/node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /opt/runner/externals/node20/bin/node)
Author   dawidd6
🌐
codestudy
codestudy.net › blog › glibc-2-27-not-found-while-installing-node-on-amazon-ec2-instance
Resolving GLIBC_2.27 and GLIBC_2.28 Not Found Errors When Installing Node.js on Amazon Linux EC2 Instance — codestudy.net
Docker container won’t start: Check Docker status with sudo systemctl status docker and ensure your user is in the docker group. The "GLIBC_2.27/2.28 not found" error on Amazon Linux EC2 is a compatibility issue between newer Node.js versions ...
🌐
Bobby Hadz
bobbyhadz.com › blog › node-glibc-not-found-required-by-node
node: version `GLIBC_2.28` not found (required by node) | bobbyhadz
April 5, 2024 - The error commonly occurs when you try to install a newer Node.js version (e.g. 18 or 19) on Amazon Linux AMI because the underlying operating system might not support the version of Node.js you're trying to install.
🌐
Frontendclub
frontendclub.net › aws-amplify-specified-node-18-but-GLIBC-not-found-on-build
AWS Amplify - Specified Node 18 but GLIBC_2.27 or GLIBC_2.28 not found on build - Frontend Club
January 6, 2023 - node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node) node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node) By default AWS Amplify uses Amazon Linux:2 as its build image and it comes with GLIBC 2.26.
🌐
AWS re:Post
repost.aws › questions › QU7-r6JOAIRE2316E0yERghw › glibc-2-25-not-found-on-amazonlinux
GLIBC_2.25 not found on AmazonLinux | AWS re:Post
January 13, 2019 - This particular package : contains the most important sets of shared libraries: the standard C : library and the standard math library. Without these two libraries, a : Linux system will not function. ... If you are running glibc 2.28 or below on RHEL 8, the OS does not include GLIBC_2.32, which is required by the precompiled aws_signing_helper binary.
🌐
GitHub
github.com › aws › q-command-line-discussions › discussions › 195
Support Older GLibc 2.26 (Amazon Linux 2) · aws/q-command-line-discussions · Discussion #195
❯ ./q/install.sh /home/aljohri/.local/bin/q: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by /home/aljohri/.local/bin/q) /home/aljohri/.local/bin/q: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by /home/aljohri/.local/bin/q) /home/aljohri/.local/bin/q: /lib64/libc.so.6: version `GLIBC_2.27' not found (required by /home/aljohri/.local/bin/q) /home/aljohri/.local/bin/q: /lib64/libc.so.6: version `GLIBC_2.29' not found (required by /home/aljohri/.local/bin/q) /home/aljohri/.local/bin/q: /lib64/libc.so.6: version `GLIBC_2.33' not found (required by /home/aljohri/.local/bin/q) /home/aljohri/.local/bin/q: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by /home/aljohri/.local/bin/q) /home/aljohri/.local/bin/q: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by /home/aljohri/.local/bin/q) Try to install Amazon Q on any Amazon Linux 2 machine.
Author   aws