100

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.

Brady Maf
  • 1,279
  • 2
  • 5
  • 12

5 Answers5

126

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

Efren
  • 4,003
  • 4
  • 33
  • 75
  • Also may want to avoid odd **node** versions, since they are deprecated faster. – Efren May 09 '22 at 06:52
  • 4
    I got this command to install the LTS version from AWS docs: nvm install --lts – Ryan Shirley Jul 12 '22 at 16:19
  • 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 problems – Dnyaneshwar Jadhav Sep 15 '22 at 12:37
  • 47
    This does not solve the issue for those who want to install node 18 – Bilow Oct 04 '22 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 06 '22 at 02:32
  • 10
    node v18.12.0, which is the latest active lts at the time of this comment, also has this error on centos. – justin.m.chase Oct 28 '22 at 21:10
  • 1
    One more problem with non standard terms, Long for node means much less time than the [majority](https://en.wikipedia.org/wiki/Long-term_support), it is probably hard to catch up at that rate of major version increases. – Efren Oct 31 '22 at 05:08
  • I have the same problem. Node 18 cannot be installed in aws EC2. – rkJun Nov 03 '22 at 02:59
  • 6
    As mentioned [elsewhere](https://stackoverflow.com/a/74298148), the problem is caused by the fact that [Amazon Linux 2 only supports glibc 2.26](https://aws.amazon.com/amazon-linux-2/lts-candidate-2-release-notes/). For newer versions you'll probably need to migrate to [Amazon LInux 2022](https://aws.amazon.com/linux/amazon-linux-2022). – djvg Nov 25 '22 at 15:17
  • Supporting other answers here. As mentioned in the [documentation](https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html#setting-up-node-on-ec2-instance-procedure:~:text=Amazon%20Linux%202%20does%20not%20currently%20support%20the%20current%20LTS%20release%20(version%2018.x)%20of%20Node.js.%20Use%20Node.js%20version%2016.x%20with%20the%20following%20command%20instead.), currently Amazon Linux 2 only supports v16 of Node as its glib version is still 2.26. – addicted Mar 26 '23 at 06:14
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.

robo360
  • 525
  • 4
  • 3
18

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.

Jeffery Bennett
  • 490
  • 1
  • 5
  • 9
14

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

rkJun
  • 311
  • 2
  • 7
-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

dynamo
  • 89
  • 2
  • 9