记录vite打包vue项目内存溢出问题及解决方法
出现问题
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 00007FF6C505158F v8::internal::CodeObjectRegistry::~CodeObjectRegistry+122159
2: 00007FF6C4FDB326 DSA_meth_get_flags+64118
3: 00007FF6C4FDC3A2 DSA_meth_get_flags+68338
4: 00007FF6C5912374 v8::Isolate::ReportExternalAllocationLimitReached+116
5: 00007FF6C58FC93D v8::SharedArrayBuffer::Externalize+781
6: 00007FF6C579FEBC v8::internal::Heap::EphemeronKeyWriteBarrierFromCode+1468
7: 00007FF6C57ACB69 v8::internal::Heap::PublishPendingAllocations+1129
8: 00007FF6C57A9B3A v8::internal::Heap::PageFlagsAreConsistent+2842
9: 00007FF6C579C799 v8::internal::Heap::CollectGarbage+2137
10: 00007FF6C579A950 v8::internal::Heap::AllocateExternalBackingStore+2000
11: 00007FF6C57BF4D6 v8::internal::Factory::NewFillerObject+214
12: 00007FF6C54F24D5 v8::internal::DateCache::Weekday+1797
13: 00007FF6C59A0051 v8::internal::SetupIsolateDelegate::SetupHeap+494417
14: 000002D6EBE1BB1F
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 解决方法一
1、根据网上的资料是通过全局下载npm包increase-memory-limit:
npm install -g increase-memory-limit
1
2、在项目目录执行命令:
increase-memory-limit
1
3.如果报错就搜索node_modules目录下的.bin目录中的 “%_prog%”
替换为%_prog%
# 解决方法二(我的解决方法)
1、全局安装cross-env
npm install -g cross-env
1
2、在package.json的scripts中的build执行命令中增加内存设置
"build": "cross-env NODE_OPTIONS=--max_old_space_size=10240 vite build"
1
上次更新: 2024/02/20, 17:31:36
- 02
- Node与GLIBC_2.27不兼容解决方案08-19
- 03
- Git清空本地文件跟踪缓存08-13