angular ng build报错内存溢出问题解决 Ineffective mark-compacts near heap limit Allocation failed - JavaScr...

1、今天项目部署,执行ng build到了92%时出现了一下报错:

1: StubFrame [pc: 000002FD4FC54719]

Security context: 0x03daafe9e6e9

    2: split [000003DAAFE906C9](this=0x031fd1a51621 ,0x03e8eeb96309 >)

    3: print(aka print) [000002471FCD3F51] [0x01c44ad026f1 :~4113] [pc=000002FD52B20540](this=0x01c44ad026f1 ,str=0x031fd1a51621 )

    4: with_block [000002471FCD3C89] [...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

1: 000000014001F04A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+5114

2: 000000013FFFA0C6 node::MakeCallback+4518

3: 000000013FFFAA30 node_module_register+2032

4: 00000001402820EE v8::internal::FatalProcessOutOfMemory+846

5: 000000014028201F v8::internal::FatalProcessOutOfMemory+639

6: 00000001407A2BC4 v8::internal::Heap::MaxHeapGrowingFactor+9556

7: 0000000140799C46 v8::internal::ScavengeJob::operator=+24310

8: 000000014079829C v8::internal::ScavengeJob::operator=+17740

9: 00000001407A0F87 v8::internal::Heap::MaxHeapGrowingFactor+2327

10: 00000001407A1006 v8::internal::Heap::MaxHeapGrowingFactor+2454

11: 000000014035CDB7 v8::internal::Factory::NewFillerObject+55

12: 00000001403F2CC6 v8::internal::WasmJs::Install+29414

这里报错显示的JavaScript 堆内存不足,在 Node 中通过 JavaScript 使用内存时只能使用部分内存(64位系统下约为1.4 GB,32位系统下约为0.7 GB),webpack 编译时就会占用很多的系统资源,如果超出了V8对 Node 默认的内存限制大小,就出现内存溢出问题。V8依然提供了选项让我们使用更多的内存。Node 在启动时可以传递 --max-old-space-size 或 --max-new-space-size 来调整内存大小的使用限制。

2、解决方案:

1.打开angular项目目录node_modules/.bin

2.分别打开ng.cmd和ngc.cmd文件,将最后一行代码修改为绿色框框中的内容即可。


3、再次执行ng build就可以成功了呢。

好了,可以下班吃饭炒饭啦。

你可能感兴趣的:(angular ng build报错内存溢出问题解决 Ineffective mark-compacts near heap limit Allocation failed - JavaScr...)