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

8

138

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.

Richthofen answered 27/4, 2022 at 2:13 Comment(3)
If the solution helped you, please consider marking as answer :)Orgulous
it work if don't close terminalBallplayer
Had a similar issue but on AWS lambda. After trying lots of things I ended up upgrading to node v 20 so to use Amazon Linux 2023 runtime. This solved my problem. docs.aws.amazon.com/lambda/latest/dg/…Reliable
O
156

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

Orgulous answered 28/4, 2022 at 4:27 Comment(10)
Also may want to avoid odd node versions, since they are deprecated faster.Orgulous
I got this command to install the LTS version from AWS docs: nvm install --ltsOrangewood
I also changed the latest version from 18 to 16, and this works for me!, AWS need to fix some bug in free tier EC2 instance, it is not working with Node 18, installation also showing problemsRother
This does not solve the issue for those who want to install node 18Rutland
@Rutland the question was for AWS, so you may have to wait for 18, check the ref document link: We recommend a version in active long-term support, which, at this writing, is the latest 16.x releaseOrgulous
node v18.12.0, which is the latest active lts at the time of this comment, also has this error on centos.Chatwin
One more problem with non standard terms, Long for node means much less time than the majority, it is probably hard to catch up at that rate of major version increases.Orgulous
I have the same problem. Node 18 cannot be installed in aws EC2.Vinic
As mentioned elsewhere, the problem is caused by the fact that Amazon Linux 2 only supports glibc 2.26. For newer versions you'll probably need to migrate to Amazon LInux 2022.Charter
Supporting other answers here. As mentioned in the documentation, currently Amazon Linux 2 only supports v16 of Node as its glib version is still 2.26.Exploiter
C
50

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.

Compendium answered 4/11, 2022 at 18:54 Comment(1)
This does not solve the issue for those who want to install node v18Amateur
O
27

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.

Oospore answered 23/12, 2022 at 4:47 Comment(1)
and because the question is about Amazon Linux, if you want to go from Node 16 to Node 18 and above, you need to start using a newer version of GLIBC, which is not available on Amazon Linux 2 = you need to move to Amazon Linux 2023Filaria
V
26

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

Vinic answered 3/11, 2022 at 4:26 Comment(2)
More about Amazon Linux 2022Charter
Honestly, this is the real answer, as much as no one wants to hear it. If you need to be running a newer version of Node, you need to run a host that supports it. The other answers just stating you should downgrade to an older Node are not really answers at all.Nye
I
1

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

Insurer answered 1/11, 2023 at 10:8 Comment(0)
S
0

👋

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!

Sokil answered 30/1 at 14:23 Comment(0)
F
0

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)
Forthcoming answered 15/2 at 15:22 Comment(0)
X
-1

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

Xylia answered 12/11, 2022 at 2:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.