致命错误:使用yarn安装模块时Javascript耗尽堆内存

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

我正在运行 React Native 应用程序。直到昨天为止都很好,但是今天我在尝试使用以下命令安装 package.json 中列出的模块时收到如下错误 纱线安装命令,不确定发生了什么,但如果我将纱线升级到浆果版本,它虽然可以工作,但无法安装应用程序,尽管我能够安装模块。不知道发生了什么:

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
javascript reactjs node.js react-native memory
1个回答
0
投票

首先尝试此操作并重建项目。

清理 Gradle 文件:

   cd android
  ./gradlew clean

删除缓存目录(从项目根目录运行):

rm -rf android/.gradle android/.idea android/app/build android/build

停止 Gradle 守护进程:(如果有)

 cd android
./gradlew --stop
© www.soinside.com 2019 - 2024. All rights reserved.