You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Angular 11执行npm run front报错:Maximum call stack size exceeded

Angular 11项目npm run front启动报错解决办法

问题详情

开发Angular 11.2.14项目时,执行npm run front触发报错,对应的脚本命令为:

node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng serve --configuration es5 --proxy-config proxy.config.json

package.json中的脚本配置如下:

"scripts": {
  "front": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng serve --configuration es5 --proxy-config proxy.config.json",
  "build:prod": "node --max_old_space_size=4800 ./node_modules/@angular/cli/bin/ng build --prod"
}

当前环境:Node v16.13.2、npm 6.14.8、Angular 11.2.14,团队使用相同版本无异常,本人无权限降级Node,设备内存16GB(可用15.4GB),错误截图如下:
Angular启动报错截图

无需降级Node的解决尝试

  • 调大Node内存分配:把--max_old_space_size从8000调高到10000,修改脚本后重新执行:
    "front": "node --max_old_space_size=10000 ./node_modules/@angular/cli/bin/ng serve --configuration es5 --proxy-config proxy.config.json"
    
  • 重置依赖缓存:清理现有依赖和缓存后重新安装
    rm -rf node_modules package-lock.json
    npm cache clean --force
    npm install
    
  • 禁用Angular CLI缓存:在启动命令末尾加--no-cache参数,避免缓存导致的异常
    "front": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng serve --configuration es5 --proxy-config proxy.config.json --no-cache"
    
  • 检查代理配置文件:确认proxy.config.json无语法错误(比如多余逗号、引号缺失),格式符合Angular代理要求
  • 释放系统内存:关闭后台不必要的进程,避免Node进程内存被其他程序挤占

内容的提问来源于stack exchange,提问作者san

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.17 14:20:50