下一个js的基本buildspec.yml

问题描述 投票:0回答:1
version: 0.2

phases:
  install:
    runtime-versions:
        nodejs: 12
    commands:
        - echo Installing dependencies with Yarn...
        - yarn set version berry  # Set Yarn Berry as the Yarn version
        - yarn install  # Use Yarn Berry to install dependencies

 build:
    commands:
        - echo Build started on `date`
        - echo Compiling the Node.js code...
        - yarn build  # Use Yarn Berry to run the build script

  post_build:
    commands:
      - echo Build completed on `date`
      - echo doing nothing

artifacts:
  files:
    - '**/*'
  discard-paths: yes

我尝试使用 AWS 服务部署非常简单的 next js 应用程序。 习惯像route53、cloudfront、codepipeline等服务...

我在本地的下一个 js 项目中使用yarn berry 作为包管理器。 所以我也尝试在我的构建规范中使用纱线浆果。 (如果可能且合理的话)

我的 aws codebuild 出现错误

agent_1  | [Container] 2023/10/28 03:04:17 Waiting for agent ping
agent_1  | [Container] 2023/10/28 03:04:48 Waiting for DOWNLOAD_SOURCE
agent_1  | [Container] 2023/10/28 03:05:10 Phase is DOWNLOAD_SOURCE
agent_1  | [Container] 2023/10/28 03:05:10 CODEBUILD_SRC_DIR=/codebuild/output/src143957957/src
agent_1  | [Container] 2023/10/28 03:05:10 YAML location is /codebuild/output/srcDownload/src/buildspec.yml
agent_1  | [Container] 2023/10/28 03:05:10 Phase complete: DOWNLOAD_SOURCE State: FAILED
agent_1  | [Container] 2023/10/28 03:05:10 Phase context status code: YAML_FILE_ERROR Message: did not find expected key at line 11
agent_1  | [Container] 2023/10/28 03:05:10 Runtime error (*clienterr.PhaseContextError: did not find expected key at line 11)
agent-resources_build_1 exited with code 11

yml 文件有什么问题? 您能给我一个用于我的目的的示例代码吗?

并让我知道在代码构建环境中使用yarn berry是否合理。 谢谢。

amazon-web-services aws-codebuild
1个回答
0
投票

您的缩进不正确。应该是:

---
version: 0.2
phases:
  install:
    runtime-versions:
      nodejs: 12
    commands:
      - echo Installing dependencies with Yarn...
      - yarn set version berry
      - yarn install
  build:
    commands:
      - echo Build started on `date`
      - echo Compiling the Node.js code...
      - yarn build
  post_build:
    commands:
      - echo Build completed on `date`
      - echo doing nothing
artifacts:
  files:
    - "**/*"
  discard-paths: yes
© www.soinside.com 2019 - 2024. All rights reserved.