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

Angular 17升级至18后执行ng serve/ng build触发colorette栈溢出错误

Angular 17升级至18后ng serve/ng build报错解决

报错信息

\app\node_modules\listr2\node_modules\colorette\index.cjs:54
head = string.substring(0, index) + replace, ^

RangeError: Maximum call stack size exceeded at String.substring
() at replaceClose (C:\Users\E02973\Desktop\n6 - Copy
(2)\app\node_modules\listr2\node_modules\colorette\index.cjs:54:17)
at replaceClose (C:\Users\E02973\Desktop\n6 -
Copy(2)\app\node_modules\listr2\node_modules\colorette\index.cjs:57:32)
(重复报错栈信息省略)
Node.js v20.17.0

解决方法

  • 清除缓存并重装依赖

    1. 执行npm cache clean --force清除npm全局缓存
    2. 删除项目目录下的node_modules文件夹和package-lock.json文件
    3. 重新安装依赖:npm install
  • 禁用颜色输出绕过问题
    执行命令时通过环境变量关闭颜色渲染:

    • Windows系统:set NO_COLOR=1 && ng serve
    • Linux/macOS系统:NO_COLOR=1 ng serve
      也可以修改package.json的scripts字段,将启动命令改为"start": "NO_COLOR=1 ng serve",后续直接运行npm start即可。
  • 强制锁定colorette兼容版本
    在项目的package.json中添加overrides字段,强制指定colorette的稳定版本:

    "overrides": {
      "colorette": "2.0.20"
    }
    

    保存后执行npm install重新安装依赖,此方法要求npm版本在8.3及以上。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.18 18:07:37