当前位置:   article > 正文

vue 热更新内存溢出 | vue-cli 2热更新内存溢出 | JavaScript堆内存不足_vue-cli vue2 内存溢出排查

vue-cli vue2 内存溢出排查

Vue nodejs热更新内存溢出

vue-cli2 脚手架搭建出来的项目,当进行部分被依赖过多的文件时,热更新后容易在94%卡住,报JavaScript heap out of memory,具体如下:

  1. 94% asset optimizationFATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
  2. 1: 00007FF7CB94ECE5
  3. 2: 00007FF7CB928196
  4. 3: 00007FF7CB928BA0
  5. 4: 00007FF7CBBB8D5E
  6. 5: 00007FF7CBBB8C8F
  7. 6: 00007FF7CC0F69D4
  8. 7: 00007FF7CC0ED137
  9. 8: 00007FF7CC0EB6AC
  10. 9: 00007FF7CC0F4627
  11. 10: 00007FF7CC0F46A6
  12. 11: 00007FF7CBC973EB
  13. 12: 00007FF7CBC99EED
  14. 13: 00007FF7CBEADF48
  15. 14: 00007FF7CBBAC26B
  16. 15: 00007FF7CBBD2406
  17. 16: 00007FF7CB91108C
  18. 17: 0000033B9F0879E0
  19. npm ERR! code ELIFECYCLE
  20. npm ERR! errno 134
  21. npm ERR! webapp@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
  22. npm ERR! Exit status 134
  23. npm ERR!
  24. npm ERR! Failed at the webapp@1.0.0 dev script.
  25. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  26. npm ERR! A complete log of this run can be found in:
  27. npm ERR! G:\nodejs\node_cache\_logs\2021-04-27T01_36_22_391Z-debug.log
  28. npm ERR! code ELIFECYCLE
  29. npm ERR! errno 134
  30. npm ERR! webapp@1.0.0 start: `npm run dev`
  31. npm ERR! Exit status 134
  32. npm ERR!
  33. npm ERR! Failed at the webapp@1.0.0 start script.
  34. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
  35. npm ERR! A complete log of this run can be found in:
  36. npm ERR! G:\nodejs\node_cache\_logs\2021-04-27T01_36_22_452Z-debug.log

原因:

vue nodejs默认配置内存大小约1.8GB,当修改被依赖过多的文件时会查找所有使用的地方,因此容易出现内存溢出情况

解决方案:

修改配置文件,扩大允许使用的内存,文件路径:./node_modules/.bin/webpack-dev-server.cmd

定位到如下内容:

"%_prog%"  "%dp0%\..\webpack-dev-server\bin\webpack-dev-server.js" %*

修改为如下内容:

"%_prog%" --max-old-space-size=4096 "%dp0%\..\webpack-dev-server\bin\webpack-dev-server.js" %*

注:单位为MB,具体配置大小可以根据个人实际情况而定。

 

参考文档:https://www.cnblogs.com/amang/p/9585008.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/640909
推荐阅读
相关标签
  

闽ICP备14008679号