赞
踩
vue-cli2 脚手架搭建出来的项目,当进行部分被依赖过多的文件时,热更新后容易在94%卡住,报JavaScript heap out of memory,具体如下:
- 94% asset optimizationFATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
- 1: 00007FF7CB94ECE5
- 2: 00007FF7CB928196
- 3: 00007FF7CB928BA0
- 4: 00007FF7CBBB8D5E
- 5: 00007FF7CBBB8C8F
- 6: 00007FF7CC0F69D4
- 7: 00007FF7CC0ED137
- 8: 00007FF7CC0EB6AC
- 9: 00007FF7CC0F4627
- 10: 00007FF7CC0F46A6
- 11: 00007FF7CBC973EB
- 12: 00007FF7CBC99EED
- 13: 00007FF7CBEADF48
- 14: 00007FF7CBBAC26B
- 15: 00007FF7CBBD2406
- 16: 00007FF7CB91108C
- 17: 0000033B9F0879E0
- npm ERR! code ELIFECYCLE
- npm ERR! errno 134
- npm ERR! webapp@1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
- npm ERR! Exit status 134
- npm ERR!
- npm ERR! Failed at the webapp@1.0.0 dev script.
- npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
-
- npm ERR! A complete log of this run can be found in:
- npm ERR! G:\nodejs\node_cache\_logs\2021-04-27T01_36_22_391Z-debug.log
- npm ERR! code ELIFECYCLE
- npm ERR! errno 134
- npm ERR! webapp@1.0.0 start: `npm run dev`
- npm ERR! Exit status 134
- npm ERR!
- npm ERR! Failed at the webapp@1.0.0 start script.
- npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
-
- npm ERR! A complete log of this run can be found in:
- 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,具体配置大小可以根据个人实际情况而定。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。