angular8 本地打包 node内存溢出导致打包失败

项目体积增大到时候,在使用build出现内存溢出导致build失败;

在网上看到的解决方法是 进入node_modules里在bin/ng 目录文件下 首行增加 

--max_old_space_size=4096
 
但是这个方法适合个人而不适合多人协作;因为node_modules可以移除,然后又要重新配置;(虽然我这个组就我一个前端!!)
 
可以在package.json 的 scripts 中配置;

   "build": "ng build",
    "build-aot": "node --max_old_space_size=4096 ./node_modules/@angular/cli/bin/ng build --prod --aot --build-optimizer",
    "build-aot-max": "ng build --prod --aot",

这样就可以适用于多人协作了

posted @ 2020-05-06 10:21  抹茶奶盖xh  阅读(647)  评论(0编辑  收藏  举报