【Vue】Reached heap limit Allocation failed - JavaScript heap out of memory

<--- Last few GCs --->                                                                                                                                
                                                                                                                                                      
[14292:040645A0]    27044 ms: Scavenge 986.7 (1044.2) -> 986.0 (1045.0) MB, 1.4 / 0.0 ms  (average mu = 0.843, current mu = 0.436) allocation failure 
[14292:040645A0]    27051 ms: Scavenge 987.3 (1045.0) -> 986.5 (1045.0) MB, 1.4 / 0.0 ms  (average mu = 0.843, current mu = 0.436) allocation failure 
[14292:040645A0]    27061 ms: Scavenge 988.0 (1045.0) -> 987.2 (1049.2) MB, 2.7 / 0.0 ms  (average mu = 0.843, current mu = 0.436) allocation failure 
                                                                                                                                                      
                                                                                                                                                      
<--- JS stacktrace --->                                                                                                                               
                                                                                                                                                      
FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory                                                                     
 1: 00E0EC6F v8::internal::Heap::AllocateExternalBackingStore+1551

如下图:打开package.json加这个命令

"serve-c1": "node --max_old_space_size=2000 node_modules/@vue/cli-service/bin/vue-cli-service.js serve --open"

然后直接 npm run serve-c1就可以了 2000 的数字根据自己需要的内存大小可以设置,但注意,如果太高也会报错,我的电脑设置成4000就会提示,发生错误。
【Vue】Reached heap limit Allocation failed - JavaScript heap out of memory_第1张图片

你可能感兴趣的:(Vue,javascript,vue.js,前端)