Using NodeJS 18 in AWS Amplify on Amazon Linux 2 fails
Asked Answered
H

6

9

Trying to upgrade an existing React app running on AWS Amplify from node v16 to v18
The image used is the provided Amazon Linux 2

Expected it to install node 18 on the machine it spun up and build the application, since this is the LTS version

Here is the error I get in the build process:

2022-11-15T19:19:02.924Z [WARNING]: 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)
Halford answered 12/12, 2022 at 9:0 Comment(1)
The majority of these answers are now outdated, see the correct answer here.Blissful
M
1

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

You can also revert back to Node.js 16 as it uses a lower version of Glibc.

Mohandas answered 12/12, 2022 at 9:6 Comment(1)
See this answerBlissful
A
2

The same problem happened to me, I fixed it by adding a custom image in the build config.

You can see the steps to add a custom image in the following link

The image that worked for me was the following:

public.ecr.aws/t7o4u3y2/node-18.2.0:latest

UPDATE

Now is available support Node 18.x

Please see the update here

Alienate answered 21/12, 2022 at 1:44 Comment(2)
If I change the image I get the following error: "aws codecommit credential-helper $@ get: 1: aws: not found" How did you manage to clone the repository?Orography
What worked for me was very similar: public.ecr.aws/docker/library/node:18.14.2. Tried pure node:18.14.2 (straight from Docker Hub) but it was frequently failing due to pull rate limits (which the docs warn about).Cramfull
B
2

As of April 2023, per this comment:

Node 18 available in the default Docker image for all builds! The version is pinned to 18.13.0, which you can leverage by simply adding the nvm use 18 command to your build spec.

version: 1
backend:
  phases:
    build:
      commands:
        - nvm use 18
        - amplifyPush --simple
Blissful answered 18/12, 2023 at 15:1 Comment(0)
M
1

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

You can also revert back to Node.js 16 as it uses a lower version of Glibc.

Mohandas answered 12/12, 2022 at 9:6 Comment(1)
See this answerBlissful
J
0

Thanks for opening this issue. Amazon Linux 2 doesn't support the right GLIBC version at the moment, we're coordinating internally to get that updated. As @saharl-neosec mentions, you can provide a custom docker image until we fully support it:

https://github.com/aws-amplify/amplify-hosting/issues/3109

Journalist answered 12/12, 2022 at 9:4 Comment(0)
M
0

To build Custom images (nodejs) for AWS Amplify follow this pattern.

public.ecr.aws/docker/library/node:your_node_version

For example if you want to use Node.js version v18.16.0

public.ecr.aws/docker/library/node:18.16.0
Mcglynn answered 2/1 at 6:43 Comment(0)
S
0

I switched to "Amazon Linux:2023" which is the default as of this writing and it fixed my issue.

I then didn't have to have any other setting to get Node 18.

Surtax answered 21/3 at 10:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.