108

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.

2
  • 3
    If the solution helped you, please consider marking as answer :)
    – Efren
    May 3, 2022 at 7:05
  • it work if don't close terminal May 23 at 11:24

5 Answers 5

133

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

10
  • 4
    I got this command to install the LTS version from AWS docs: nvm install --lts Jul 12, 2022 at 16:19
  • 50
    This does not solve the issue for those who want to install node 18
    – Bilow
    Oct 4, 2022 at 16:17
  • 3
    @Bilow 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 release
    – Efren
    Oct 6, 2022 at 2:32
  • 10
    node v18.12.0, which is the latest active lts at the time of this comment, also has this error on centos. Oct 28, 2022 at 21:10
  • 7
    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.
    – djvg
    Nov 25, 2022 at 15:17
40

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.

1
  • 3
    This does not solve the issue for those who want to install node v18
    – aksyuma
    Jun 10 at 12:36
22

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.

15

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
-3

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.