I have an Amazon Linux 2023 EC2 Instance. I have a node app on this instance and when I run 'npm run dev', it runs fine, but when I run 'npm run build' It doesn't. I am able to run both commands on my local terminal fine with no issues.
When I run 'npm run build' on the EC2 instance, I get the following error:
transforming (2092) node_modules/zrender/lib/animation/easing.jsUse of eval is strongly discouraged, as it poses security risks and may cause issues with minification
<--- Last few GCs --->
[1316431:0x63d0810] 88078 ms: Mark-Compact 468.0 (485.6) -> 464.1 (485.9) MB, 1105.19 / 0.00 ms (average mu = 0.275, current mu = 0.310) allocation failure; scavenge might not succeed
[1316431:0x63d0810] 89129 ms: Mark-Compact 468.1 (485.9) -> 464.8 (486.6) MB, 976.06 / 0.00 ms (average mu = 0.203, current mu = 0.071) allocation failure; scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0xc8e4a0 node::Abort() [node]
2: 0xb6b8f3 [node]
3: 0xeacb10 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
4: 0xeacdf7 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [node]
5: 0x10be465 [node]
6: 0x10be9f4 v8::internal::Heap::RecomputeLimits(v8::internal::GarbageCollector) [node]
7: 0x10d58e4 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::internal::GarbageCollectionReason, char const*) [node]
8: 0x10d60fc v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
9: 0x10ac401 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
10: 0x10ad595 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [node]
11: 0x108ab06 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [node]
12: 0x14e5936 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [node]
13: 0x191eef6 [node]
I then try running export NODE_OPTIONS="--max-old-space-size=1024" to increase the heap limit but when I run build after this, it just seems to hang forever at the below:
transforming (2086) node_modules/zrender/lib/svg/cssAnimation.jsUse of eval is strongly discouraged, as it poses security risks and may cause issues with minification
✓ 2094 modules transformed.
I have tried on Amazon linux 2023 and Amazon Linux 2, with both producing the same issue.
Thanks for your reply. No other processes running, this is a brand new instance I created only to run this node app. Instance type is t2.micro Let me know if anything else you need to know.