1

在构建我的打字稿项目时,即我运行npm run build,脚本看起来像"build": "webpack",我收到以下错误。

它抱怨内存不足,即使 vscode 只消耗大约 2GB 的 RAM,而且我还有很多 (10+GB) 剩余。

知道是什么原因造成的吗?清除 node_modules 或安装其他 webpack 版本没有帮助。我也已经用谷歌搜索了一整天......

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
4

1 回答 1

0

事实证明,其中一个依赖项依赖于比我引用的更高的打字稿版本(在我的情况下3.3.3333,而我在引用3.0.3)。

当我升级我的 typescript 依赖项时package.json,错误消失了,我可以再次构建。

于 2019-03-19T16:03:34.460 回答