当我运行 ng update
将 Angular 7 升级到 8 时,我在@angular/core 迁移期间收到“内存不足”错误:
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
这并不特别令人惊讶 - 当我运行 ng build
时,我也遇到了 Out of memory
。作为解决方案,我们运行 npm run build
,它被配置为 node --max_old_space_size=10240 ./node_modules/@angular/cli/bin/ng build
所以,我的问题是如何为包@angular/core 配置迁移以使用更多内存?
更新:按照建议,我重新运行更新
node --max_old_space_size=10240 ./node_modules/.bin/ng update @angular/core --from 7 --to 8 --migrate-only
但是我得到一个错误:
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
似乎引号是针对 Linux 环境的,但在 Windows 上会中断...
最佳答案
按照 this 中的说明尝试此命令 node --max_old_space_size=10240 node_modules/.bin/ng update
GitHub 问题。
更新:
看起来您还可以自定义 ng
命令调用,如 this 中所述发布。
或者您可以将节点升级到版本 12,它应该会自动调整运行命令所需的内存。
关于angular - 升级 Angular 7 -> 8 内存不足,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56409444/