FATAL ERROR: Javascript run out of heapMemory while install modules using yarn

i am running the react native app. It was good till yesterday, but today i am getting the error as below, while I am trying to install the modules listed in the package.json using the
yarn install command, not sure what is happening, but if i upgrade the yarn to berry version it works though, but unable to install the app, though i was able to install the modules. not sure what is happening:

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
----- Native stack trace -----

 1: 0x1001a7eb8 node::OOMErrorHandler(char const*, v8::OOMDetails const&) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
 2: 0x10033662c v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, v8::OOMDetails const&) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
 3: 0x10050ad00 v8::internal::Heap::GarbageCollectionReasonToString(v8::internal::GarbageCollectionReason) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
 4: 0x1005097dc v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
 5: 0x1004ffff4 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
 6: 0x100500854 v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
 7: 0x1004e58c4 v8::internal::Factory::NewFillerObject(int, v8::internal::AllocationAlignment, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
 8: 0x1008cd5d4 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
 9: 0x100c2cc44 Builtins_CEntry_Return1_ArgvOnStack_NoBuiltinExit [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
10: 0x100c48664 Builtins_ArrayPrototypeJoin [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
11: 0x105fee3d4 
12: 0x105ff7d04 
13: 0x105fdc654 
14: 0x100ba43e4 Builtins_InterpreterEntryTrampoline [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
15: 0x100ba43e4 Builtins_InterpreterEntryTrampoline [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
16: 0x100bdd4c4 Builtins_GeneratorPrototypeNext [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
17: 0x105f50610 
18: 0x105ddeb2c 
19: 0x100ba43e4 Builtins_InterpreterEntryTrampoline [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
20: 0x100ba43e4 Builtins_InterpreterEntryTrampoline [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
21: 0x100bdd4c4 Builtins_GeneratorPrototypeNext [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
22: 0x105f50610 
23: 0x105ddeb2c 
24: 0x100ba43e4 Builtins_InterpreterEntryTrampoline [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
25: 0x100ba43e4 Builtins_InterpreterEntryTrampoline [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
26: 0x100bdd4c4 Builtins_GeneratorPrototypeNext [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
27: 0x105f65944 
28: 0x100c88fb8 Builtins_PromiseFulfillReactionJob [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
29: 0x100bcab94 Builtins_RunMicrotasks [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
30: 0x100ba23f4 Builtins_JSRunMicrotasksEntry [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
31: 0x100478180 v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
32: 0x10047866c v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
33: 0x100478848 v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
34: 0x10049fa14 v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
35: 0x1004a01b0 v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
36: 0x1000d0c4c node::InternalCallbackScope::Close() [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
37: 0x1000d0fe4 node::InternalMakeCallback(node::Environment*, v8::Local<v8::Object>, v8::Local<v8::Object>, v8::Local<v8::Function>, int, v8::Local<v8::Value>*, node::async_context) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
38: 0x1000e7070 node::AsyncWrap::MakeCallback(v8::Local<v8::Function>, int, v8::Local<v8::Value>*) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
39: 0x1001ad2f0 node::fs::FSReqCallback::Reject(v8::Local<v8::Value>) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
40: 0x1001adb9c node::fs::FSReqAfterScope::Reject(uv_fs_s*) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
41: 0x1001addc0 node::fs::AfterNoArgs(uv_fs_s*) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
42: 0x1001a1d44 node::MakeLibuvRequestCallback<uv_fs_s, void (*)(uv_fs_s*)>::Wrapper(uv_fs_s*) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
43: 0x100b7e0e0 uv__work_done [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
44: 0x100b81b30 uv__async_io [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
45: 0x100b93c08 uv__io_poll [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
46: 0x100b820f4 uv_run [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
47: 0x1000d16f0 node::SpinEventLoopInternal(node::Environment*) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
48: 0x1001e7b64 node::NodeMainInstance::Run(node::ExitCode*, node::Environment*) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
49: 0x1001e7878 node::NodeMainInstance::Run() [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
50: 0x10016f654 node::Start(int, char**) [/Users/riktam/.nvm/versions/node/v20.18.0/bin/node]
51: 0x194084274 start [/usr/lib/dyld]
zsh: abort      yarn install