安装node v10.14.2 后
启动公司的VUE项目
使用命令npm run dev 命令
报错:
<--- Last few GCs --->[20940:00000244699848E0] 215872 ms: Scavenge 1690.2 (1836.4) -> 1679.6 (1836.4) MB, 5.4 / 0.7 ms (average mu = 0.266, current mu = 0.253) allocation failure
[20940:00000244699848E0] 216022 ms: Scavenge 1699.5 (1844.0) -> 1682.3 (1837.9) MB, 9.8 / 4.0 ms (average mu = 0.266, current mu = 0.253) allocation failure
[20940:00000244699848E0] 216476 ms: Scavenge 1694.6 (1837.9) -> 1685.7 (1837.9) MB, 15.7 / 0.3 ms (average mu = 0.266, current mu = 0.253) external memory pressure<--- JS stacktrace --->FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory1: 00007FF6806D401F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+1125112: 00007FF680663146 DSA_meth_get_flags+655423: 00007FF680663FFD node::OnFatalError+3014: 00007FF680F95ADE v8::Isolate::ReportExternalAllocationLimitReached+945: 00007FF680F8000D v8::SharedArrayBuffer::Externalize+7816: 00007FF680E235FC v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+14687: 00007FF680E302A9 v8::internal::Heap::PublishPendingAllocations+11298: 00007FF680E2D27A v8::internal::Heap::PageFlagsAreConsistent+28429: 00007FF680E1FEF9 v8::internal::Heap::CollectGarbage+2137
10: 00007FF680E2879B v8::internal::Heap::GlobalSizeOfObjects+331
11: 00007FF680E6ECCB v8::internal::StackGuard::HandleInterrupts+891
12: 00007FF680B776D6 v8::internal::DateCache::Weekday+8630
13: 00007FF6810234B1 v8::internal::SetupIsolateDelegate::SetupHeap+494417
14: 000002446C59367C
Done in 218.33s.
看了很多解决办法:
解决方案1:通过 increase-memory-limit 插件
安装插件:npm install -g increase-memory-limit
执行命令:npx cross-env LIMIT=4096 increase-memory-limit
来源:FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of me-CSDN博客
解决方案2:设置max-old-space-size即可。在工程目录node_modules.bin下找到umi.cmd文件,替换下面代码,重新启动即可。
@IF EXIST "%~dp0\node.exe" ("%~dp0\node.exe" --max_old_space_size=8192 "%~dp0\..\umi\bin\umi.js" %*
) ELSE (@SETLOCAL@SET PATHEXT=%PATHEXT:;.JS;=;%node --max_old_space_size=8192 "%~dp0\..\umi\bin\umi.js" %*
)
来源:FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out..._画画认真学习呀的博客-CSDN博客解决方案3:环境变量中设置max-old-space-size即可
个人推荐第三种,不影响项目,且通用