Vue Vite打包失败 - JavaScript heap out of memory

最近下载了一个Vue的后台项目但是在打包发布的时候报错

<--- Last few GCs --->

[8356:0979FBF0]    73866 ms: Mark-sweep 987.9 (1043.4) -> 980.7 (1044.2) MB, 929.4 / 0.0 ms  (average mu = 0.141, current mu = 0.075) allocation failure; scavenge might not succeed
[8356:0979FBF0]    74853 ms: Mark-sweep 988.9 (1044.4) -> 983.7 (1047.4) MB, 944.3 / 0.0 ms  (average mu = 0.094, current mu = 0.043) allocation failure; scavenge might not succeed


<--- JS stacktrace --->

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0167CD8B v8::internal::Heap::PageFlagsAreConsistent+3323
 2: 01670A67 v8::internal::Heap::CollectGarbage+1767
 3: 01684D77 v8::internal::HeapAllocator::AllocateRawWithLightRetrySlowPath+2439

解决方法是修改package.json

把原来的

"build":"vite build"

修改成

"build": "node --max_old_space_size=4028 ./node_modules/vite/bin/vite.js build"

但是注意,这个4028也不能太大,太大了也报错


© 2016-2024 阿尔佛 aerfo.com | 豫ICP备17044542号 | 豫公网安备 41010602000172