首页
Preview

nodejs yarn build报错JavaScript heap out of memory

[success] [nitro] Generated public .output/public
[info] [nitro] Building Nitro Server (preset: `node-server`)
<--- Last few GCs --->
[24991:0x63e5ed0]   216913 ms: Mark-sweep 2006.0 (2082.4) -> 1990.5 (2083.4) MB, 1365.2 / 0.0 ms  (average mu = 0.145, current mu = 0.044) allocation failure scavenge might not succeed
[24991:0x63e5ed0]   218319 ms: Mark-sweep 2007.0 (2083.7) -> 1991.6 (2084.7) MB, 1329.5 / 0.0 ms  (average mu = 0.102, current mu = 0.054) allocation failure scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0xb08e80 node::Abort() [/usr/bin/node]
 2: 0xa1b70e  [/usr/bin/node]
 3: 0xce1890 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/bin/node]
 4: 0xce1c37 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/bin/node]
 5: 0xe992a5  [/usr/bin/node]
 6: 0xe99d86  [/usr/bin/node]
 7: 0xea82ae  [/usr/bin/node]
 8: 0xea8cf0 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/bin/node]
 9: 0xeabc6e v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/usr/bin/node]
10: 0xe6d1aa v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/usr/bin/node]
11: 0x11e5f96 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/usr/bin/node]
12: 0x15d9c19  [/usr/bin/node]
error Command failed with signal "SIGABRT".
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

产生这个报错的原因是,node的内存不足。

我们仅需修改package.json的scripts命令即可 NODE_OPTIONS='--max-old-space-size=4096'

示例:

"build": "NODE_OPTIONS='--max-old-space-size=4096' nuxi build",

版权声明:本文内容由TeHub注册用户自发贡献,版权归原作者所有,TeHub社区不拥有其著作权,亦不承担相应法律责任。 如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

点赞(0)
收藏(0)
出于随性
快乐程序员

评论(0)

添加评论