升级 Angular 7 -> 8 内存不足

Upgrade Angular 7 -> 8 runs out of memory

当我 运行宁 ng update 将 Angular 7 升级到 8 时,我在 @angular/core 迁移期间收到 "Out of memory" 错误:

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 "[=13=]" | sed -e 's,\,/,g')")
      ^^^^^^^

SyntaxError: missing ) after argument list

似乎引号是针对 Linux 环境的,在 Windows...

时中断

按照 this GitHub 问题中的说明尝试此命令 node --max_old_space_size=10240 node_modules/.bin/ng update

更新:

看起来您还可以自定义 ng 命令调用,如 this post 中所述。

或者您可以将节点升级到版本 12,它应该会自动调整 运行 命令所需的内存。