Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 937
Ollie Avatar asked Sep 11 '25 19:09

Ollie


2 Answers

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.

like image 186
Ollie Avatar answered Sep 14 '25 07:09

Ollie


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:

  • uninstall and install node in CodeBuild: when we ran node --version it still said 12
  • install and manage versions with nvm: ran into problems getting the nvm command to register

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

In the end, no complicated commands needed.

like image 45
Bofei Cao Avatar answered Sep 14 '25 09:09

Bofei Cao