我有一个Vue应用程序。为该应用程序运行yarn build
时失败,并显示错误,例如“致命错误:CALL_AND_RETRY_LAST分配失败-JavaScript堆内存不足”
显然不会崩溃...仅重新启动,然后错误再次出现
yarn serve
没有显示任何错误
我已经尝试使用--max_old_space_size,但是它不起作用。
Building for production...
<--- Last few GCs --->
[15106:0x104800000] 59679 ms: Scavenge 1309.5 (1404.6) -> 1308.7 (1405.1) MB, 17.1 / 0.0 ms (average mu = 0.183, current mu = 0.186) allocation failure
[15106:0x104800000] 59705 ms: Scavenge 1320.1 (1415.6) -> 1319.2 (1416.1) MB, 11.5 / 0.0 ms (average mu = 0.183, current mu = 0.186) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x0ed65f71e681 <JSObject>
0: builtin exit frame: lastIndexOf(this=0x0ed64fe8cd29 <Very long string[2749756]>,0x0ed684c307e9 <String[1]\: \n>,0x0ed64fe8cd29 <Very long string[2749756]>)
1: z(aka z) [0xed64d5f89f9] [/Users/aracelicanadas/Desktop/unilever/unilever_ui/node_modules/terser/dist/bundle.min.js:1] [bytecode=0xed694d21061 offset=15](this=0x0ed6cad826f1 <undefined>)
2: prepend_comments [0xed64d5f86c1] ...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x10003927a node::Abort() [/usr/local/Cellar/node/10.10.0/bin/node]
2: 0x10003944b node::OnFatalError(char const*, char const*) [/usr/local/Cellar/node/10.10.0/bin/node]
3: 0x1001aca27 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node/10.10.0/bin/node]
4: 0x1001ac9c8 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node/10.10.0/bin/node]
5: 0x10047f740 v8::internal::Heap::UpdateSurvivalStatistics(int) [/usr/local/Cellar/node/10.10.0/bin/node]
6: 0x1004813b3 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/Cellar/node/10.10.0/bin/node]
7: 0x10047ea79 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/Cellar/node/10.10.0/bin/node]
8: 0x10047d964 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/Cellar/node/10.10.0/bin/node]
9: 0x1004860bf v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/Cellar/node/10.10.0/bin/node]
10: 0x100486108 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/Cellar/node/10.10.0/bin/node]
11: 0x100465fef v8::internal::Factory::AllocateRawWithImmortalMap(int, v8::internal::PretenureFlag, v8::internal::Map*, v8::internal::AllocationAlignment) [/usr/local/Cellar/node/10.10.0/bin/node]
12: 0x100467dbf v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/usr/local/Cellar/node/10.10.0/bin/node]
13: 0x10054c801 v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag) [/usr/local/Cellar/node/10.10.0/bin/node]
14: 0x1005679f4 v8::internal::String::LastIndexOf(v8::internal::Isolate*, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [/usr/local/Cellar/node/10.10.0/bin/node]
15: 0x10024a531 v8::internal::Builtin_Impl_StringPrototypeLastIndexOf(v8::internal::BuiltinArguments, v8::internal::Isolate*) [/usr/local/Cellar/node/10.10.0/bin/node]
16: 0x354b4c8dc17d
17: 0x354b4c8918b5
18: 0x354b4d494285
19: 0x354b4d43de3c
20: 0x354b4c88a5a3
⠙ Building for production...
答案 0 :(得分:0)
更新或使用更大的堆内存大小无法解决问题的根源。
根本原因是您可能在package.json
文件中包含了无限循环依赖项。
如果包名称为“ anAwesomePackage”,并且在package.json依赖项内部,则将其自身列为依赖项,则可能发生这种情况:
package.json:
{
"name": "anAwesomePackage",
...
"dependencies": {
"anAwesomePackage": "latest"
}
}
npm
足够聪明,知道该怎么做,yarn
不是。