JavaScript heap out of memory – NextJS

I was running my NextJs project and during development, it broke for an unknown reason and logged this error message:

<--- Last few GCs --->

[8728:000001A567CE5290]  8719226 ms: Mark-sweep (reduce) 1827.7 (1944.2) -> 1827.7 (1897.2) MB, 668.1 / 0.0 ms  (average mu = 0.411, current mu = 0.171) last resort; GC in old space requested

[8728:000001A567CE5290]  8720395 ms: Mark-sweep (reduce) 1827.7 (1897.2) -> 1827.7 (1889.5) MB, 1169.6 / 0.0 ms  (average mu = 0.173, current mu = 0.000) last resort; GC in old space requested

<--- JS stacktrace --->

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory

1: 00007FF72EB507BF node_api_throw_syntax_error+175823

2: 00007FF72EAD5796 DSA_meth_get_flags+59654

3: 00007FF72EAD7480 DSA_meth_get_flags+67056

4: 00007FF72F57DCC4 v8::Isolate::ReportExternalAllocationLimitReached+116

5: 00007FF72F569052 v8::Isolate::Exit+674

6: 00007FF72F3FFB6E v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath+4030

7: 00007FF72F40703A v8::internal::Factory::CodeBuilder::AllocateCode+106 

8: 00007FF72F407CF1 v8::internal::Factory::CodeBuilder::BuildInternal+641

9: 00007FF72F407956 v8::internal::Factory::CodeBuilder::Build+22

10: 00007FF72EE59BC7 v8::internal::RegExpMacroAssemblerX64::GetCode+4215  

11: 00007FF72F125AAE v8::internal::RegExpErrorString+9390

12: 00007FF72F10FCF1 v8::PropertyDescriptor::value+6081

13: 00007FF72F11020C v8::internal::RegExp::CompileForTesting+764

14: 00007FF72F1107F8 v8::internal::RegExp::DotPrintForTesting+248

15: 00007FF72F11187B v8::internal::RegExp::ExperimentalOneshotExec+2795   

16: 00007FF72F11138D v8::internal::RegExp::ExperimentalOneshotExec+1533   

17: 00007FF72F110CD8 v8::internal::RegExp::Exec+216

18: 00007FF72F0EEBC2 v8::internal::DeclarationScope::was_lazily_parsed+22994

19: 00007FF72F61B1F1 v8::internal::SetupIsolateDelegate::SetupHeap+558193 

20: 00007FF72F67DE8A v8::internal::SetupIsolateDelegate::SetupHeap+962826 

21: 00007FF6AFBA1BBA

I was trying to run my project on my local machine. But I am curious to know what you think the cause might be.