Angular编译提示js heap out of memory

1.错误信息

==== JS stack trace =========================================

Security context: 0000006FC6325879
2: collapse_single_use_vars(aka collapse_single_use_vars) [000001F6E9B022D1 :5984] [bytecode=0000028FD3EF5C79 offset=371](this=000001F6E9B022D1 ,statements=0000022C620C65B1 ,compressor=0000008A4A9DFC71 )
3: tighten_body(aka tighten_body) [000001F6E9B022D1 :~5915] [pc=0000004A56C4F3A2](this=000001F6E9B022D1 …

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node_module_register
2: v8::internal::FatalProcessOutOfMemory
3: v8::internal::FatalProcessOutOfMemory
4: v8::internal::Factory::NewTransitionArray
5: v8::internal::SourcePositionTableIterator::Advance
6: v8::internal::SourcePositionTableIterator::Advance
7: v8::internal::JSReceiver::GetOwnPropertyDescriptor
8: v8::internal::JSReceiver::GetOwnPropertyDescriptor
9: v8::internal::JSReceiver::GetOwnPropertyDescriptor
10: v8::internal::JSReceiver::class_name
11: v8::internal::JSReceiver::GetOwnPropertyDescriptor
12: v8::internal::LookupIterator::PrepareTransitionToDataProperty
13: v8::internal::operator<<
14: v8::internal::operator<<
15: v8::internal::operator<<
16: v8::internal::operator<<
17: v8::internal::operator<<
18: 0000004A567043C1
npm ERR! code ELIFECYCLE
npm ERR! errno 3

2.分析及解决方法

通常Angular编译错误应直接先看fatal error,然后再看error。此处fatal error 提示很明确,即JavaScript堆内存不足导致溢出。事实上,由于nodejs、html5等偏向于应用层面逻辑编写的原因,使得并不像c/c++可以在编写代码的时候去详细考虑如何处理内存占用与释放的问题。因此针对这种问题,直接使用工具增加堆内存使满足编译需要即可。方法如下:
在工程目录下执行:
1.npm install -g increase-memory-limit
2.increase-memory-limit

你可能感兴趣的:(Angular,编译与运行错误)