[AWS CodeBuild]引擎“节点”与此模块不兼容。预期版本&quot> = 14.0.0&quort。获得“ 10.19.0”

发布于 2025-01-22 09:24:09 字数 3517 浏览 2 评论 0 原文

我正在尝试通过AWS Codepipeline和CodeBuild部署我的React应用程序。

但是,CodeBuild失败了以下错误:

[Container] 2022/04/19 02:42:19 Waiting for agent ping
[Container] 2022/04/19 02:42:29 Waiting for DOWNLOAD_SOURCE
[Container] 2022/04/19 02:42:30 Phase is DOWNLOAD_SOURCE
[Container] 2022/04/19 02:42:30 CODEBUILD_SRC_DIR=/codebuild/output/src234015054/src
[Container] 2022/04/19 02:42:30 YAML location is /codebuild/output/src234015054/src/buildspec.yml
[Container] 2022/04/19 02:42:30 Processing environment variables
[Container] 2022/04/19 02:42:30 [WARN] Skipping install of runtimes. Runtime version selection is not supported by this build image.
[Container] 2022/04/19 02:42:33 Moving to directory /codebuild/output/src234015054/src
[Container] 2022/04/19 02:42:33 Expanded cache path ./node_modules/**/*
[Container] 2022/04/19 02:42:33 Configuring ssm agent with target id: codebuild:0a77403f-035c-4d62-b96e-de5449f7f4bc
[Container] 2022/04/19 02:42:33 Successfully updated ssm agent configuration
[Container] 2022/04/19 02:42:33 Registering with agent
[Container] 2022/04/19 02:42:33 Phases found in YAML: 2
[Container] 2022/04/19 02:42:33  INSTALL: 2 commands
[Container] 2022/04/19 02:42:33  BUILD: 1 commands
[Container] 2022/04/19 02:42:33 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2022/04/19 02:42:33 Phase context status code:  Message: 
[Container] 2022/04/19 02:42:33 Entering phase INSTALL
[Container] 2022/04/19 02:42:33 Running command echo Performing yarn install
Performing yarn install

[Container] 2022/04/19 02:42:33 Running command yarn install
yarn install v1.22.4
[1/5] Validating package.json...
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.0.0". Got "10.19.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

我不知道为什么在此处选择CodeBuild 10.19.0

更多信息

我正在使用纱线构建构建软件包的 。我可以使用纱线启动运行该应用程序,而不会在本地出现问题。

这是我的buildspec.yml:

version: 0.2
phases:
  install:
    runtime-versions:
      nodejs: 14
    commands:
      - echo Performing yarn install
      - yarn install
  build:
    commands:
      - yarn build

artifacts:
  base-directory: ./build
  files:
    - "**/*"

cache:
  paths:
    - "./node_modules/**/*"

节点版本,

 "name": "my-package",
  "version": "0.1.0",
  "private": true,
  "engines": {
    "node": ">=14.0.0",
    "npm": ">=8.5.5"
  },

我还指定了 package.json :使用解决方案更新的

我可以根据FedOnev@的答案解决问题。

正如他所说,我需要配置构建映像以使用 codebuild.linuxbuildimage.standard_5_0 在CodeBuild项目中。

// AWS CodePipeline stage to build website
pipeline.addStage({
  stageName: "Build",
  actions: [
    // AWS CodePipeline action to run CodeBuild project
    new codepipeline_actions.CodeBuildAction({
      actionName: "BuildeWebsite",
      project: new CodeBuild.PipelineProject(this, "BuildWebsite", {
        projectName: "BuildeWebsite",
        environment: {
          buildImage: CodeBuild.LinuxBuildImage.STANDARD_5_0
        },
        buildSpec:
          CodeBuild.BuildSpec.fromSourceFilename("./buildspec.yml"),
      }),
      input: outputSources,
      outputs: [outputWebsite],
    }),
  ],
});

I'm trying to deploy my React application through AWS codepipeline and codebuild.

However, codebuild failed with below error:

[Container] 2022/04/19 02:42:19 Waiting for agent ping
[Container] 2022/04/19 02:42:29 Waiting for DOWNLOAD_SOURCE
[Container] 2022/04/19 02:42:30 Phase is DOWNLOAD_SOURCE
[Container] 2022/04/19 02:42:30 CODEBUILD_SRC_DIR=/codebuild/output/src234015054/src
[Container] 2022/04/19 02:42:30 YAML location is /codebuild/output/src234015054/src/buildspec.yml
[Container] 2022/04/19 02:42:30 Processing environment variables
[Container] 2022/04/19 02:42:30 [WARN] Skipping install of runtimes. Runtime version selection is not supported by this build image.
[Container] 2022/04/19 02:42:33 Moving to directory /codebuild/output/src234015054/src
[Container] 2022/04/19 02:42:33 Expanded cache path ./node_modules/**/*
[Container] 2022/04/19 02:42:33 Configuring ssm agent with target id: codebuild:0a77403f-035c-4d62-b96e-de5449f7f4bc
[Container] 2022/04/19 02:42:33 Successfully updated ssm agent configuration
[Container] 2022/04/19 02:42:33 Registering with agent
[Container] 2022/04/19 02:42:33 Phases found in YAML: 2
[Container] 2022/04/19 02:42:33  INSTALL: 2 commands
[Container] 2022/04/19 02:42:33  BUILD: 1 commands
[Container] 2022/04/19 02:42:33 Phase complete: DOWNLOAD_SOURCE State: SUCCEEDED
[Container] 2022/04/19 02:42:33 Phase context status code:  Message: 
[Container] 2022/04/19 02:42:33 Entering phase INSTALL
[Container] 2022/04/19 02:42:33 Running command echo Performing yarn install
Performing yarn install

[Container] 2022/04/19 02:42:33 Running command yarn install
yarn install v1.22.4
[1/5] Validating package.json...
error [email protected]: The engine "node" is incompatible with this module. Expected version ">=14.0.0". Got "10.19.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

I don't know why codebuild picked 10.19.0 here.

More Info

I'm using yarn build to build package. I can run the app with yarn start without problem locally.

Here is my buildspec.yml:

version: 0.2
phases:
  install:
    runtime-versions:
      nodejs: 14
    commands:
      - echo Performing yarn install
      - yarn install
  build:
    commands:
      - yarn build

artifacts:
  base-directory: ./build
  files:
    - "**/*"

cache:
  paths:
    - "./node_modules/**/*"

I also specified the node version in package.json:

 "name": "my-package",
  "version": "0.1.0",
  "private": true,
  "engines": {
    "node": ">=14.0.0",
    "npm": ">=8.5.5"
  },

Update With Solution

I'm able to solve the issue based on fedonev@'s answer.

As he said, I need configure the build image to use CodeBuild.LinuxBuildImage.STANDARD_5_0 in CodeBuild Project.

// AWS CodePipeline stage to build website
pipeline.addStage({
  stageName: "Build",
  actions: [
    // AWS CodePipeline action to run CodeBuild project
    new codepipeline_actions.CodeBuildAction({
      actionName: "BuildeWebsite",
      project: new CodeBuild.PipelineProject(this, "BuildWebsite", {
        projectName: "BuildeWebsite",
        environment: {
          buildImage: CodeBuild.LinuxBuildImage.STANDARD_5_0
        },
        buildSpec:
          CodeBuild.BuildSpec.fromSourceFilename("./buildspec.yml"),
      }),
      input: outputSources,
      outputs: [outputWebsite],
    }),
  ],
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

肥爪爪 2025-01-29 09:24:09

您还必须配置CodeBuild项目以使用 支持Nodejs v14 Runtime 。 Ubuntu Standard 5图像是目前唯一的图像。在云形象中:

Type: AWS::CodeBuild::Project
Properties: 
  Environment:
    Image: "aws/codebuild/standard:5.0"

You must also configure the CodeBuild Project to use a build image that supports the Nodejs v14 runtime. The Ubuntu Standard 5 image is the only image that does at the moment. In CloudFormation:

Type: AWS::CodeBuild::Project
Properties: 
  Environment:
    Image: "aws/codebuild/standard:5.0"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文