You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS CodeBuild指定Node.js14.x运行时报版本不支持错误咨询

AWS CodeBuild Node.js 14版本适配解决方案

问题根因

你当前使用的aws/codebuild/amazonlinux2-x86_64-standard:3.0构建镜像,最高仅内置支持Node.js 10、12两个版本,无内置Node.js 14运行时包,因此会触发版本不存在的报错。

方案1:升级构建镜像(推荐)

  • 进入CodeBuild项目的「环境配置」页面,将原有构建镜像替换为aws/codebuild/amazonlinux2-x86_64-standard:4.0及更高版本,该系列镜像默认内置Node.js 14运行时
  • 修改buildspec配置中runtime-versions的nodejs值为14,不要带.x后缀,完整配置示例:
version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 14

  build:
    commands:
      - node -v # 可选,执行构建前验证Node.js版本是否符合预期
      - "npm i"
      - "npm run build"
      - "npm run db:migrate"

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

方案2:不更换镜像手动安装Node.js 14

如果因业务限制暂时无法升级构建镜像,可跳过runtime-versions配置,在install阶段直接安装Node.js 14,配置示例:

version: 0.2

phases:
  install:
    commands:
      - curl -sL https://rpm.nodesource.com/setup_14.x | bash -
      - yum install -y nodejs
  build:
    commands:
      - node -v
      - "npm i"
      - "npm run build"
      - "npm run db:migrate"

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

内容的提问来源于stack exchange,提问作者Ollie

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 10:24:04