我在Fedora虚拟机上运行Jenkins并拥有由create-react-app创建的应用程序。
当我尝试在我的本地计算机上进行生产时,大约8分钟后,它会成功编译(尽管有消息:'捆绑包大小明显大于推荐...'
但是,当我在Jenkins构建过程中运行相同的脚本时,出现以下错误:FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
。
构建脚本如下:npm run build-css && node --max_old_space_size=8192 node_modules/.bin/react-scripts-ts build && npm run copy-to-build
。
我的问题是,如何为在Fedora上运行的虚拟机分配更多内存,以便在抛出FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
之前脚本可以成功运行。
答案 0 :(得分:6)
我的解决方案是按照here所述在.env.production文件中设置GENERATE_SOURCEMAP=false
。
更好的解决方案(虽然更耗时)是code split巨大的文件(> 1MB)