라이브러리가 커지면서 npm build시에 아래와 같은 에러가 발생하는 경우가 있다.
<--- Last few GCs --->
[460:000001FBC1662AB0] 139935 ms: Scavenge 4029.6 (4120.4) -> 4026.3 (4137.7) MB, 11.7 / 0.0 ms (average mu = 0.869, current mu = 0.535) allocation failure;
[460:000001FBC1662AB0] 141755 ms: Mark-sweep 4039.3 (4137.7) -> 4030.5 (4145.9) MB, 1753.6 / 0.0 ms (average mu = 0.761, current mu = 0.486) allocation failure; scavenge might not succeed
<--- JS stacktrace --->
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF660F52BCF node_api_throw_syntax_error+175519
2: 00007FF660ED83A6 SSL_get_quiet_shutdown+64006
3: 00007FF660ED9762 SSL_get_quiet_shutdown+69058
4: 00007FF66197FDD4 v8::Isolate::ReportExternalAllocationLimitReached+116
5: 00007FF66196B132 v8::Isolate::Exit+674
6: 00007FF6617ECF8C v8::internal::EmbedderStackStateScope::ExplicitScopeForTesting+124
7: 00007FF6617EA1AB v8::internal::Heap::CollectGarbage+3963
8: 00007FF6618003E3 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath+2099
9: 00007FF661800C8D v8::internal::HeapAllocator::AllocateRawWithRetryOrFailSlowPath+93
10: 00007FF6618095DA v8::internal::Factory::AllocateRaw+810
11: 00007FF66181FEFA v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArrayWithFiller+90
12: 00007FF66181FE0D v8::internal::FactoryBase<v8::internal::Factory>::NewFixedArray+77
13: 00007FF66162594F v8::internal::LookupIterator::wasm_value_type+27055
14: 00007FF661627023 v8::internal::LookupIterator::wasm_value_type+32899
15: 00007FF661626797 v8::internal::LookupIterator::wasm_value_type+30711
16: 00007FF661504F03 v8::internal::DateCache::Weekday+15763
17: 00007FF6615051EC v8::internal::DateCache::Weekday+16508
18: 00007FF661A1D371 v8::internal::SetupIsolateDelegate::SetupHeap+558193
19: 00007FF5E318E132
이때는 아래와 같이 처리해주면 된다.
$ node -e 'console.log(v8.getHeapStatistics().heap_size_limit/(1024*1024))'
$ 499.25
$ export NODE_OPTIONS=--max_old_space_size=8000
export NODE_OPTIONS=--max_old_space_size=8000
커맨드는 어디에 둬야하나요?