GLIBC_2.27 not found while installing Node on Amazon EC2 instance

194.3k Views Asked by At

I'm trying to install Nodejs on Amazon linux machine, I'm following this documentation to install node https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html but I'm getting below error when I execute this command nvm install node

How can I fix this issue? Any help would be much appreciated. Thanks!

v18.0.0 is already installed.
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)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `nvm use --delete-prefix v18.0.0` to unset it.
[ec2-user@ip-xx-xxx-xx-xx ~]$ node -e "console.log('Running Node.js ' + process.version)"
-bash: node: command not found

I tried running this nvm use --delete-prefix v18.0.0 but no luck.

8

There are 8 best solutions below

0
On

In My scenario it's OS issue. OS need to upgraded:

My Current OS version is: Red Hat Enterprise Linux Server 7.9 (Maipo)

cat /etc/os-release

I got below issue for node-18 install

    node: /lib64/libm.so.6: version `GLIBC_2.27' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.25' not found (required by node)
node: /lib64/libc.so.6: version `GLIBC_2.28' not found (required by node)
node: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by node)
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by node)
node: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by node)

Check ldd version as above issue

ldd --version

Upgraded OS version with: Red Hat Enterprise Linux 8.2 (Ootpa) and issue got resolved.

ldd version should be more than ldd (GNU libc) 2.27

10
On

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

1
On

The error message:

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)

is telling you that you do not have a new enough version of glibc for nvm to install node 18. The error tells you it requires at least glibc 2.27.

You can find your current glibc version with: ldd --version

It's possible that you can install a newer version of glibc using a package manager like apt-get.

You can find the latest available version of glibc available via your package manager with: apt-cache policy libc6.

If your package manager can't install a new-enough version of glibc, you need to be on a newer version of your operating system. In Ubuntu, you can accomplish an OS upgrade with do-release-upgrade.

0
On

There is some issue with nvm latest version 18.x.x.

Try following steps to resolve the issue

1.Uninstall your nvm

$ nvm uninstall <nvm_version>

ie. $ nvm uninstall 18.12.2

2.Install stable version of nvm

$ nvm install <stable_nvm_version>

ie. $ nvm install 16.0.0

0
On

Ran into a bit of a snag while working through the AWS tutorial on spinning up a React app with Amplify and GraphQL. Thought I'd share the hiccup and the fix, just in case anyone else finds themselves in the same boat.

The Issue: GLIBC Error: If you're like me and went with Node.js v18 (because why not, right?), you might hit a GLIBC_2.27 not found error during the Amplify build process. Turns out, the AWS Amplify build environment isn't quite on board with Node.js v18 due to some GLIBC version mismatches.

Package Compatibility: So, the obvious move is to dial back Node.js to an earlier version, but here's the kicker - doing that breaks [email protected] because it's expecting Node.js v18. You get slapped with an "incompatible engine" error, and you're back to square one.

The Fix: After a bit of tinkering, I landed on a setup that works. Here's the amplify.yml that finally got things rolling:

version: 1
backend:
  phases:
    build:
      commands:
        - '# Execute Amplify CLI with the helper script'
        - amplifyPush --simple
frontend:
  phases:
    preBuild:
      commands:
        - nvm install 17.9.1 # Rolling back to Node.js v17.9.1
        - nvm use 17.9.1
        - npm install -g yarn # Still gotta have my yarn!
        - yarn install --ignore-engines # This is the game-changer
    build:
      commands:
        - nvm use 17.9.1
        - yarn run build
  artifacts:
    baseDirectory: build
    files:
      - '**/*'
  cache:
    paths:
      - node_modules/**/*

Dropped down to Node.js 17.9.1 to sidestep the GLIBC drama. Slapped on --ignore-engines with yarn install to keep react-hook-form happy without it fussing over the Node version. Hope this saves you a headache or two. Happy coding!

0
On

This (credits) worked for me on node 18:

  • Go to AWS Amplify
  • From the side menu, under App settings, select Build settings
  • On the page, scroll down to Build image settings
  • Click Edit, an Edit build image settings modal will show up.
  • Under Build image section, click on dropdown and select Build image
  • Paste public.ecr.aws/docker/library/node:18.17.0 in Reference build image input (Note: Other than node version 18.17.0, you can also search for specific version of node on https://gallery.ecr.aws/docker/library/node)
2
On

Amazon Linux 2 or some os includes glibc 2.26 or under. To use a higher glib version, you need to consider other AMI. for example) Amazon Linux 2022. (al2022-ami) it includes glibc 2.34

reference : https://repost.aws/questions/QUrXOioL46RcCnFGyELJWKLw/glibc-2-27-on-amazon-linux-2

1
On

It seems like you are using v.18.0.0 which was the latest but not well-supported.

Try uninstalling that.

nvm uninstall 18.0.0

Install a version that is active.

nvm install 16.0.0

You should now be using v16 which should be well-supported.