【问题标题】:Codebuild latest node version mismatched with EC2Codebuild 最新节点版本与 EC2 不匹配
【发布时间】:2022-06-17 10:28:12
【问题描述】:

有没有人遇到过 Codebuild 的节点 14 的最新版本是 14.19.2 但 EC2 支持的节点 14 的最新版本是 14.19.1

由于 Codebuild 不支持指定次要版本,我一直坚持使用 14.19.2 进行构建,然后在构建完成后无法部署,因为 EC2 中的节点版本不匹配。

来自 Codebuild 的日志:

> [Container] 2022/05/21 14:21:15 Running command echo "Installing
> Node.js version 14 ..." Installing Node.js version 14 ...
> 
> [Container] 2022/05/21 14:21:15 Running command n $NODE_14_VERSION
>      copying : node/14.19.2    installed : v14.19.2 (with npm 6.14.17)

从部署到 EC2 的日志:

[1/5] Validating package.json...

2022-05-21T06:53:18.834-07:00   error my-app@0.1.2: The engine "node" is incompatible with this module. Expected version "14.19.1". Got "14.19.2"

2022-05-21T06:53:18.834-07:00   error Found incompatible module.

【问题讨论】:

    标签: node.js aws-codepipeline aws-codebuild


    【解决方案1】:

    不完美,但我更改了我的 package.json 以允许两个版本,现在它可以构建和部署。

    "engines": {
      "node": "14.X"
    },
    

    Codebuild 支持比 EC2 更高的版本仍然很奇怪。

    【讨论】:

      【解决方案2】:

      我还没有尝试过,但也许这样可以做到。

      # buildspec.yml
      version: 0.2
      phases:
        install:
          commands:
            - n 14.19.2 # Specify version
        pre_build:
          commands:
            - node -v
      

      仅供参考:https://blog.serverworks.co.jp/specific-nodejs-version-in-codebuild

      【讨论】:

        猜你喜欢
        • 2021-03-06
        • 2020-03-11
        • 1970-01-01
        • 2020-08-12
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-02-27
        相关资源
        最近更新 更多