是什么导致此Webpack内存不足异常?

时间:2019-03-19 16:03:34

标签: javascript webpack out-of-memory npm-run

在构建我的打字稿项目时,即我运行public bool containsWord(Node node, String word, int idx){ if (idx == word.length() -1){ return node.isCompleteWord; } else { if (!node.children.containsKey(word.charAt(idx)){ // no child with this letter, the word is not in the trie return false; } else { return containsWord(node.children(word.charAt(idx)), word, idx+1); } } } ,而脚本看起来像npm run build,则出现以下错误。

它抱怨内存不足,尽管vscode仅消耗大约2GB的RAM,而我仍然有足够的内存(10 + GB)。

有什么想法会导致这种情况吗?清除node_modules或安装其他Webpack版本无济于事。我已经在Google上搜索了整整一天的时间...

"build": "webpack"

1 个答案:

答案 0 :(得分:0)

事实证明,其中一个依赖项依赖于比我引用的版本更高的打字稿版本(在我的情况下,0: ExitFrame [pc: 00000059E33DC5C1] Security context: 0x00aa77a1e6e1 <JSObject> 1: getIntersectionType(aka getIntersectionType) [0000005345B7BA31] [<...>\node_modules\typescript\lib\typescript.js:~37293] [pc=00000059E43C3A49](this=0x017ebc8026f1 <undefined>,types=0x0276c2202699 <JSArray[5]>,aliasSymbol=0x017ebc8026f1 <undefined>,aliasTypeArguments=0x017ebc8026f1 <undefined>) 2: arguments adaptor frame: 1->3 ... FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 00007FF6024B08AA v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4810 2: 00007FF602489C46 node::MakeCallback+4518 3: 00007FF60248A630 node_module_register+2160 4: 00007FF60271AA4E v8::internal::FatalProcessOutOfMemory+846 5: 00007FF60271A97F v8::internal::FatalProcessOutOfMemory+639 6: 00007FF602C58984 v8::internal::Heap::MaxHeapGrowingFactor+11476 7: 00007FF602C4F0E7 v8::internal::ScavengeJob::operator=+25543 8: 00007FF602C4D65C v8::internal::ScavengeJob::operator=+18748 9: 00007FF602C565D7 v8::internal::Heap::MaxHeapGrowingFactor+2343 10: 00007FF602C56656 v8::internal::Heap::MaxHeapGrowingFactor+2470 11: 00007FF6027F9457 v8::internal::Factory::NewFillerObject+55 12: 00007FF60289113A v8::internal::WasmJs::Install+29530 13: 00000059E33DC5C1 npm ERR! code ELIFECYCLE npm ERR! errno 134 npm ERR! <project name> build: `webpack` npm ERR! Exit status 134 而我引用的是3.3.3333)。

当我在3.0.3中升级打字稿依赖项时,错误消失了,我可以再次构建。