AWS CodeBuild + CodePipeline:“CLIENT_ERROR 消息:找不到 dist 的匹配基本目录路径”

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

我尝试通过 AWS CodeBuild 服务构建节点应用程序,每次都会失败并出现相同的错误“CLIENT_ERROR 消息:找不到 dist 的匹配基本目录路径”

  • 以下是 AWS CodeBuild 错误消息的完整详细信息:

    致命错误:接近堆限制的标记压缩无效分配失败 - JavaScript 堆内存不足 ----- 本机堆栈跟踪 -----

    1: 0xb84bd6 节点::OOMErrorHandler(char const*, v8::OOMDetails const&) [节点] 2: 0xefec30 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [节点] 3: 0xefef17 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [节点] 4: 0x1110925 [节点] 5: 0x1110eb4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [节点] 6: 0x1127da4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [节点] 7: 0x11285bc v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [节点] 8: 0x10fe8c1 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [节点] 9: 0x10ffa55 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [节点] 10: 0x10dd0a6 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [节点] 11: 0x1537e36 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [节点] 12: 0x1971ef6 [节点] ·ELIFECYCLE· 命令失败。 /codebuild/output/tmp/script.sh:第 4 行:208 中止(核心转储)pnpm run build

    [Container] 2024/12/12 04:51:22.450155 命令未成功退出 pnpm run build exit status 134 [容器] 2024/12/12 04:51:22.536649 阶段完成:构建状态:失败 [Container] 2024/12/12 04:51:22.537551 阶段上下文状态代码:COMMAND_EXECUTION_ERROR 消息:执行命令时出错:pnpm run build。原因:退出状态134 [容器] 2024/12/12 04:51:22.586937 进入 POST_BUILD 阶段 [容器] 2024/12/12 04:51:22.589239 阶段完成:POST_BUILD 状态:成功 [Container] 2024/12/12 04:51:22.589253 阶段上下文状态码: 消息: [Container] 2024/12/12 04:51:22.675216 扩展基目录路径:dist [Container] 2024/12/12 04:51:22.678545 正在组装文件列表 [集装箱] 2024/12/12 04:51:22.678560 扩大分布 [Container] 2024/12/12 04:51:22.681759 跳过无效的文件路径 dist [Container] 2024/12/12 04:51:22.682241 将报告自动发现超时设置为 5 秒 [容器] 2024/12/12 04:51:22.683461 扩展基本目录路径: . [Container] 2024/12/12 04:51:22.686542 正在组装文件列表 [容器] 2024/12/12 04:51:22.686557 正在扩展 . [Container] 2024/12/12 04:51:22.689705 扩展基本目录的文件路径。 [Container] 2024/12/12 04:51:22.689717 正在组装文件列表 [容器] 2024/12/12 04:51:22.689720 扩展中 */ [容器] 2024/12/12 04:51:24.044619 找到 13 个文件 [Container] 2024/12/12 04:51:24.044796 报告自动发现文件发现花费了 1.362555 秒 [容器] 2024/12/12 04:51:24.045872 阶段完成:UPLOAD_ARTIFACTS 状态:FAILED [Container] 2024/12/12 04:51:24.045888 阶段上下文状态代码:CLIENT_ERROR 消息:找不到 dist 的匹配基本目录路径 找不到 dist

    的匹配基本目录路径
node.js pipeline cicd aws-codebuild codebuild
1个回答
0
投票

我能够通过修改 buildspec.yml 文件解决该问题。

问题之前buildspec.yml文件:

version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 20.12.2
    commands:
      - npm install -g pnpm # Install pnpm globally

  pre_build:
    commands:
      - echo Installing dependencies
      - pnpm install

  build:
    commands:
      - pnpm run build

artifacts:
  files:
    - '**/*'
  base-directory: dist

解决问题的Buildspec.yml 文件:

version: 0.2

phases:
  install:
    runtime-versions:
      nodejs: 20.12.2
    commands:
      - npm install -g pnpm # Install pnpm globally

  pre_build:
    commands:
      - echo Installing dependencies
      - pnpm install

  build:
    commands:
      - export NODE_OPTIONS="--max-old-space-size=4096"
      - pnpm run build

artifacts:
  files:
    - '**/*'
  base-directory: dist

这里的主要问题是堆内存问题,Node.js 进程尝试分配比允许或可用更多的内存。

© www.soinside.com 2019 - 2024. All rights reserved.