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.
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.
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:
node --version
it still said 12nvm
command to registerThen we realized that n was already pre-installed in CodeBuild and managing the node version.
In the end, no complicated commands needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With