Reputation: 357
I am trying to build the node app through the AWS CodeBuild service and every time its failing with the same error "CLIENT_ERROR Message: no matching base directory path found for dist"
Here is the full detail of the AWS CodeBuild error message:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory ----- Native stack trace -----
1: 0xb84bd6 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [node] 2: 0xefec30 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node] 3: 0xefef17 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node] 4: 0x1110925 [node] 5: 0x1110eb4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node] 6: 0x1127da4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node] 7: 0x11285bc v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node] 8: 0x10fe8c1 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node] 9: 0x10ffa55 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node] 10: 0x10dd0a6 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node] 11: 0x1537e36 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node] 12: 0x1971ef6 [node] ·ELIFECYCLE· Command failed. /codebuild/output/tmp/script.sh: line 4: 208 Aborted (core dumped) pnpm run build
[Container] 2024/12/12 04:51:22.450155 Command did not exit successfully pnpm run build exit status 134 [Container] 2024/12/12 04:51:22.536649 Phase complete: BUILD State: FAILED [Container] 2024/12/12 04:51:22.537551 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: pnpm run build. Reason: exit status 134 [Container] 2024/12/12 04:51:22.586937 Entering phase POST_BUILD [Container] 2024/12/12 04:51:22.589239 Phase complete: POST_BUILD State: SUCCEEDED [Container] 2024/12/12 04:51:22.589253 Phase context status code: Message: [Container] 2024/12/12 04:51:22.675216 Expanding base directory path: dist [Container] 2024/12/12 04:51:22.678545 Assembling file list [Container] 2024/12/12 04:51:22.678560 Expanding dist [Container] 2024/12/12 04:51:22.681759 Skipping invalid file path dist [Container] 2024/12/12 04:51:22.682241 Set report auto-discover timeout to 5 seconds [Container] 2024/12/12 04:51:22.683461 Expanding base directory path: . [Container] 2024/12/12 04:51:22.686542 Assembling file list [Container] 2024/12/12 04:51:22.686557 Expanding . [Container] 2024/12/12 04:51:22.689705 Expanding file paths for base directory . [Container] 2024/12/12 04:51:22.689717 Assembling file list [Container] 2024/12/12 04:51:22.689720 Expanding */ [Container] 2024/12/12 04:51:24.044619 Found 13 file(s) [Container] 2024/12/12 04:51:24.044796 Report auto-discover file discovery took 1.362555 seconds [Container] 2024/12/12 04:51:24.045872 Phase complete: UPLOAD_ARTIFACTS State: FAILED [Container] 2024/12/12 04:51:24.045888 Phase context status code: CLIENT_ERROR Message: no matching base directory path found for dist no matching base directory path found for dist
Upvotes: 0
Views: 54
Reputation: 357
I was able to solve the issue by modifying the buildspec.yml file.
Before the issue buildspec.yml file:
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 file that solved the issue:
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
The main issue here was with the Heap Memory issue where the Node.js process tries to allocate more memory than is allowed or available.
Upvotes: 0