title: FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory
body: <p>Error:</p>
  
  <pre><code>&lt;--- Last few GCs ---&gt;
  
  [873:0x1020aa000]    47109 ms: Scavenge 2107.9 (2131.9) -&gt; 2092.1 (2131.9) MB, 0.3 / 0.0 ms  (average mu = 0.995, current mu = 0.999) allocation failure 
  [873:0x1020aa000]    47231 ms: Scavenge 2107.9 (2131.9) -&gt; 2092.1 (2131.9) MB, 0.2 / 0.0 ms  (average mu = 0.995, current mu = 0.999) allocation failure 
  [873:0x1020aa000]    47353 ms: Scavenge 2107.9 (2131.9) -&gt; 2092.1 (2131.9) MB, 0.2 / 0.0 ms  (average mu = 0.995, current mu = 0.999) allocation failure 
  
  
  &lt;--- JS stacktrace ---&gt;
  
  ==== JS stack trace =========================================
  
      0: ExitFrame [pc: 0x27af028cfc7d]
  Security context: 0x00a9d921d971 &lt;JSObject&gt;
      1: push [0xa9d9205831](this=0x00a92dc86431 &lt;JSArray[112813858]&gt;,0x00a9f2d5fdf1 &lt;String[17]\: \n                &gt;)
      2: /* anonymous */ [0xa92dc86471] [0x00a9bba025b1 &lt;undefined&gt;:~1] [pc=0x27af02959ff7](this=0x00a9051847e1 &lt;JSGlobal Object&gt;,0x00a92dc86531 &lt;Object map = 0xa982312831&gt;,0x00a9f2d4f6a9 &lt;JSFunction exports.escapeXML (sfi = 0xa9f2d4edc9)&gt;,0x00...
  
  FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory
   1: 0x100060e87 node::Abort() [/usr/local/Cellar/node/11.10.1/bin/node]
   2: 0x1000614f5 node::OnFatalError(char const*, char const*) [/usr/local/Cellar/node/11.10.1/bin/node]
   3: 0x10017a687 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node/11.10.1/bin/node]
   4: 0x10017a628 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/Cellar/node/11.10.1/bin/node]
   5: 0x100437638 v8::internal::Heap::UpdateSurvivalStatistics(int) [/usr/local/Cellar/node/11.10.1/bin/node]
   6: 0x10041de6a v8::internal::Factory::AllocateRawFixedArray(int, v8::internal::PretenureFlag) [/usr/local/Cellar/node/11.10.1/bin/node]
   7: 0x10041d781 v8::internal::Factory::NewFixedArrayWithFiller(v8::internal::Heap::RootListIndex, int, v8::internal::Object*, v8::internal::PretenureFlag) [/usr/local/Cellar/node/11.10.1/bin/node]
   8: 0x1003dce56 v8::internal::(anonymous namespace)::ElementsAccessorBase&lt;v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits&lt;(v8::internal::ElementsKind)2&gt; &gt;::ConvertElementsWithCapacity(v8::internal::Handle&lt;v8::internal::JSObject&gt;, v8::internal::Handle&lt;v8::internal::FixedArrayBase&gt;, v8::internal::ElementsKind, unsigned int, unsigned int, unsigned int, int) [/usr/local/Cellar/node/11.10.1/bin/node]
   9: 0x1003dcd0c v8::internal::(anonymous namespace)::ElementsAccessorBase&lt;v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits&lt;(v8::internal::ElementsKind)2&gt; &gt;::GrowCapacityAndConvertImpl(v8::internal::Handle&lt;v8::internal::JSObject&gt;, unsigned int) [/usr/local/Cellar/node/11.10.1/bin/node]
  10: 0x1003db82a v8::internal::(anonymous namespace)::ElementsAccessorBase&lt;v8::internal::(anonymous namespace)::FastPackedObjectElementsAccessor, v8::internal::(anonymous namespace)::ElementsKindTraits&lt;(v8::internal::ElementsKind)2&gt; &gt;::Add(v8::internal::Handle&lt;v8::internal::JSObject&gt;, unsigned int, v8::internal::Handle&lt;v8::internal::Object&gt;, v8::internal::PropertyAttributes, unsigned int) [/usr/local/Cellar/node/11.10.1/bin/node]
  11: 0x1005068dc v8::internal::JSObject::AddDataElement(v8::internal::Handle&lt;v8::internal::JSObject&gt;, unsigned int, v8::internal::Handle&lt;v8::internal::Object&gt;, v8::internal::PropertyAttributes) [/usr/local/Cellar/node/11.10.1/bin/node]
  12: 0x100505a38 v8::internal::Object::AddDataProperty(v8::internal::LookupIterator*, v8::internal::Handle&lt;v8::internal::Object&gt;, v8::internal::PropertyAttributes, v8::internal::ShouldThrow, v8::internal::Object::StoreFromKeyed) [/usr/local/Cellar/node/11.10.1/bin/node]
  13: 0x10060fd43 v8::internal::Runtime::SetObjectProperty(v8::internal::Isolate*, v8::internal::Handle&lt;v8::internal::Object&gt;, v8::internal::Handle&lt;v8::internal::Object&gt;, v8::internal::Handle&lt;v8::internal::Object&gt;, v8::internal::LanguageMode) [/usr/local/Cellar/node/11.10.1/bin/node]
  14: 0x100612c8c v8::internal::Runtime_SetProperty(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/Cellar/node/11.10.1/bin/node]
  15: 0x27af028cfc7d 
  [nodemon] app crashed - waiting for file changes before starting...
  </code></pre>
  
  <p>I am getting this error every time I run my app.js file and click on a page, it tries to load for a minute without success and then crash. I know this question been asked before.</p>
  
  <p>However, I have tried:</p>
  
  <pre><code>export NODE_OPTIONS=--max_old_space_size=4096
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>node --max_old_space_size=4096 app.js
  </code></pre>
  
  <p>and then run my app.js and problem still the same. I am not sure where my exported variables go, cannot find the .bashrc file anywhere etc. I am not even sure what's wrong, I am a bit new into coding.</p>