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

升级至Angular 19遇TS2304错误:找不到QRCodeModule

解决Angular 19中angularx-qrcode@19.0.0的QRCodeModule找不到问题

针对你遇到的TS2304: Cannot find name 'QRCodeModule'错误,可按以下步骤排查解决:

  • 确认导入语句正确性
    angularx-qrcode@19.0.0的正确导入路径为angularx-qrcode,务必在模块代码顶部添加导入语句:

    import { QRCodeModule } from 'angularx-qrcode';
    

    遗漏这条语句是最常见的出错原因。

  • 重新安装依赖并清理缓存
    执行以下命令确保依赖安装完整,同时清除Angular缓存:

    npm install
    npx ng cache clean
    
  • 重启TypeScript语言服务
    若使用VSCode,按下Ctrl+Shift+P(Windows/Linux)或Cmd+Shift+P(Mac),输入并执行Restart TS Server,让编辑器重新识别新安装包的类型定义。

  • 检查tsconfig.json配置
    确保tsconfig.json的compilerOptions中moduleResolution设置为bundler或node16(Angular 19默认应为bundler),避免旧解析方式导致的识别问题:

    {
      "compilerOptions": {
        "moduleResolution": "bundler"
      }
    }
    

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.14 02:22:33