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

Angular 12升级至13时@types/ws类型报错求助

解决Angular 13升级后@types/ws的TS2315错误

这个错误是因为@types/ws版本与项目中@types/node版本不兼容,导致HTTPServer、HTTPSServer的泛型定义冲突引发的。以下是可行的解决步骤:

  • 卸载当前的@types/ws包:
    npm uninstall @types/ws
    
  • 安装与Angular 13兼容的指定版本@types/ws(推荐8.x系列,比如8.5.3):
    npm install @types/ws@8.5.3 --save-dev
    
  • 若问题仍存在,检查并升级@types/node版本(Angular 13适配@types/node@16.x版本):
    npm install @types/node@16 --save-dev
    
  • 最后清理依赖缓存并重新安装:
    # Linux/Mac环境
    rm -rf node_modules package-lock.json
    npm install
    
    # Windows环境
    rmdir /s /q node_modules && del package-lock.json
    npm install
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 12:07:13