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),错误截图如下:
无需降级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
相关产品推荐
相关产品推荐

