纱线构建 - 崩溃错误 JavaScript 堆内存不足 [英] Yarn build - Crashes error JavaScript heap out of memory

查看:46
本文介绍了纱线构建 - 崩溃错误 JavaScript 堆内存不足的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Vue 应用程序.为该应用程序运行 yarn build 时失败,错误为致命错误:CALL_AND_RETRY_LAST 分配失败 - JavaScript 堆内存不足"

I have a Vue application. while running yarn build for that application it is failing with error as " FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory"

显然没有崩溃...只是重新启动并再次出现错误

Apparently not crash... only restart and the error appears again

yarn serve 没有显示任何错误

我已经尝试使用 --max_old_space_size ,但它不起作用.

I've already try using --max_old_space_size , but it doesn't work.

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...

推荐答案

更新或使用更大的堆内存大小并不能解决问题的根源.

Updating or using a bigger heap memory size won't fix the root of the problem.

根本原因是您可能在 package.json 文件中包含无限循环依赖项.

The root is that you're probably including an infinite loop dependency in your package.json file.

如果您的包名称是anAwesomePackage",并且在它的 package.json 依赖项中,您将自身列为依赖项,则可能会发生这种情况:

That can happen if i.e your package name is "anAwesomePackage", and inside it's package.json dependencies, you list itself as a dependency like so:

package.json:

{
  "name": "anAwesomePackage",
  ...
  "dependencies": {
    "anAwesomePackage": "latest"
  }
}

npm 足够聪明,可以弄清楚要做什么,yarn 不是.

npm is smart enough to figure what to do, yarn isn't.

这篇关于纱线构建 - 崩溃错误 JavaScript 堆内存不足的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆