AWS CodeBuild error: Major version of alias '14.x' is not supported in runtime 'nodejs'
Asked Answered
D

3

24

I have a confusing issue with AWS CodeBuild. I am getting the following error:

Major version of alias '14.x' is not supported in runtime 'nodejs'

When I update the buildspec to simply be "14" I get slightly more information on the error:

Message: Unknown runtime version named '14' of nodejs. This build image has the following versions: 10, 12

We have been using this CodeBuild project for a long time using 12.x and now require to update to 14.x. We have updated the buildspec as follows:

version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 14.x

  build:
    commands:
      - "npm i"
      - "npm run build"
      - "npm run db:migrate"

artifacts:
  files:
    - "all"
    - "of"
    - "our"
    - "files"

Additionally, our CodeBuild is already on the latest version of the CodeBuild image. I have even re-built the CodeBuild project to make sure it is the latest and still the same issue:

aws/codebuild/amazonlinux2-x86_64-standard:3.0

Thank you in advance for any advice.

Deborahdeborath answered 2/12, 2021 at 19:59 Comment(0)
D
41

Thankfully we have solved this now!

The issue was with the CodeBuild image:

aws/codebuild/amazonlinux2-x86_64-standard:3.0

As per the available runtimes documentation it turns out we cannot use Amazon Linux 2 at all, we had to change to "Ubuntu Standard 5".

I hope this helps someone in the future.

Deborahdeborath answered 3/12, 2021 at 16:3 Comment(3)
6 months later and still the latest version of node on amazon linux codebuild images is 12 - a version that is now totally out of supportBonnie
@Bonnie Are you able to run the codebuild on "Ubuntu Standard 6" now? I still seem to get the same error even after AWS saying it supports nodejs 16 in codebuild nowBrendonbrenk
This answer would be much more helpful if you provided the actual image source you replaced it with (aws/codebuild/standard:5.0). Found here: docs.aws.amazon.com/codebuild/latest/userguide/…Binford
S
18

If you absolutely need to use Amazon Linux 2 instead of Ubuntu, you can install Node 14 using the pre-installed n package in CodeBuild:

version: 0.2

phases:
  install:
    commands:
      - n 14.18.3

  build:
    commands:
      - npm i #etc

In our case we needed to build dependencies to run in Lambda. Since Lambda runs a version of Amazon Linux 2, building these dependencies in Ubuntu didn't work (for complicated sub-dependency reasons).

Tried and didn't work:

Then we realized that n was already pre-installed in CodeBuild and managing the node version.

In the end, no complicated commands needed.

Strow answered 19/1, 2022 at 19:39 Comment(2)
Thanks for your reply, this is actually really useful for the future as we'll be deploying to Lambda at some point. Thanks again!Deborahdeborath
Thanks. This is the only solution worked for meTypeset
F
4

select the build image that supports your runtime from here https://docs.aws.amazon.com/codebuild/latest/userguide/available-runtimes.html

Faze answered 28/1, 2022 at 21:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.