Angular7 踩坑记录
1. Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
ng build --aot --prod
70% building 1315/1315 modules 0 active
<--- Last few GCs --->
[18192:00000284F6E8DAA0] 192948 ms: Mark-sweep 1980.9 (2068.2) -> 1967.4 (2067.4) MB, 496.7 / 0.0 ms (average mu = 0.363, current mu = 0.388) allocation failure scavenge might not succeed
[18192:00000284F6E8DAA0] 193652 ms: Mark-sweep 1981.3 (2067.6) -> 1967.3 (2067.9) MB, 496.2 / 0.0 ms (average mu = 0.330, current mu = 0.294) allocation failure scavenge might not succeed
<--- JS stacktrace --->
==== JS stack trace =========================================
Security context: 0x017e1eb40911 <JSObject>
0: builtin exit frame: stringify(this=0x017e1eb4a8b1 <Object map = 000003103C0418A9>,0x00a5bda404d1 <undefined>,0x00a5bda404d1 <undefined>,0x01ccaaf93cb9 <Object map = 000002C2E2E4A2C9>,0x017e1eb4a8b1 <Object map = 000003103C0418A9>)
eb\node_modules\enhanced-r...
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF7A66A8CBF napi_wrap+121791
2: 00007FF7A66520E6 v8::base::CPU::has_sse+34310
3: 00007FF7A6652F86 v8::base::CPU::has_sse+38054
4: 00007FF7A6E37E2E v8::Isolate::ReportExternalAllocationLimitReached+94
5: 00007FF7A6E2017A v8::SharedArrayBuffer::Externalize+842
6: 00007FF7A6CB197C v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1436
7: 00007FF7A6CB989F v8::internal::Heap::OldGenerationSizeOfObjects+4879
8: 00007FF7A6CAFB43 v8::internal::Heap::CollectGarbage+1235
9: 00007FF7A6CAE3D4 v8::internal::Heap::AddRetainedMap+2292
10: 00007FF7A6CD49F3 v8::internal::Factory::NewRawOneByteString+83
11: 00007FF7A6A1096C v8::internal::StringStream::ClearMentionedObjectCache+9708
12: 00007FF7A6BF319E v8::internal::LayoutDescriptor::Trim+17838
13: 00007FF7A6BF4BA8 v8::internal::LayoutDescriptor::Trim+24504
14: 00007FF7A6BF6BBE v8::internal::LayoutDescriptor::Trim+32718
15: 00007FF7A6BF9840 v8::internal::LayoutDescriptor::Trim+44112
16: 00007FF7A6D93124 v8::internal::Builtins::builtin_handle+97748
17: 00007FF7A6EE0C1D v8::internal::SetupIsolateDelegate::SetupHeap+614861
18: 00007FF7A6E4E35C v8::internal::SetupIsolateDelegate::SetupHeap+14604
19: 000001673EF31158
打包时node 内存不足。
解决方法:(在项目下运行如下命令进行打包)
# D:\node\node_modules\@angular\cli\bin 是本机angular-cli 安装目录并非项目下cli 目录
node --max_old_space_size=8192 D:\node\node_modules\@angular\cli\bin\ng build --aot --prod
2. The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'
解决方法:
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest