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

安装xng-breadcrumb 9.0.0后Angular项目启动失败及兼容问题求助

Angular项目启动问题解决方案

问题1:xng-breadcrumb 9.0.0版本兼容报错

排查与解决

  • 确认本地Angular核心版本:执行ng version,查看@angular/core版本。xng-breadcrumb 9.x强制要求Angular 14.0.0+,若版本低于14,需升级Angular;若已满足14+,则处理依赖缓存。
  • 清理依赖缓存:删除node_modules、package-lock.json(或yarn.lock),重新执行npm install(或yarn install)。
  • 匹配xng-breadcrumb版本:若安装旧版无效,需根据Angular版本选择对应xng-breadcrumb版本(如Angular13对应8.x,Angular12对应7.x),执行指定版本安装,例:npm install xng-breadcrumb@8.0.0。

问题2:ToastInjector属性类型不兼容报错

排查与解决

  • 检查自定义ToastInjector:若项目中自定义了ToastInjector类并继承Injector,需确保get方法签名与Angular官方Injector.get完全一致。官方签名示例:
    get<T>(token: Type<T> | InjectionToken<T>, notFoundValue?: T, flags?: InjectFlags): T;
    
    修正方法的参数类型、可选性及返回值类型。
  • 第三方库兼容问题:若ToastInjector来自第三方库(如ngx-toastr),需更新该库至与当前Angular版本兼容的版本,或调整Angular版本适配库要求。
  • 清理构建缓存:执行ng cache clean后重新启动项目ng serve。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.09 18:15:51