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

Angular14引入NgxMatIntlTelInputModule报错求助

解决Angular 14中导入NgxMatIntlTelInputModule的静态引用错误

针对你遇到的“Value at position 6 in the NgModule.imports of AppModule is not a reference; Value could not be determined statically”错误,可按以下步骤排查解决:

  • 确保静态导入模块
    Angular 14的AOT编译器要求模块导入必须是静态可解析的引用,禁止使用条件导入、动态导入或变量引用。检查你的AppModule代码,确保导入方式如下:

    import { NgxMatIntlTelInputModule } from 'ngx-mat-intl-tel-input';
    
    @NgModule({
      declarations: [AppComponent],
      imports: [
        // 其他必要模块(如BrowserModule、MatFormFieldModule等)
        NgxMatIntlTelInputModule // 直接静态引用,无任何条件判断
      ],
      bootstrap: [AppComponent]
    })
    export class AppModule { }
    

    若之前用了类似imports: [someCondition ? NgxMatIntlTelInputModule : []]的写法,必须移除条件逻辑。

  • 匹配依赖版本兼容性
    ngx-mat-intl-tel-input的版本需要与Angular 14兼容。执行以下命令安装适配Angular 14的指定版本:

    npm uninstall ngx-mat-intl-tel-input
    npm i ngx-mat-intl-tel-input@^4.0.0 --save
    

    该版本的peerDependencies明确支持Angular 14及对应版本的Angular Material。

  • 清理缓存并重建项目
    缓存问题可能导致编译异常,执行以下命令清理后重新构建:

    ng clean
    npm install
    ng build
    
  • 检查导入拼写与包路径
    确认模块导入的拼写完全正确,且确实从ngx-mat-intl-tel-input包导入,避免因路径错误或大小写问题导致的引用异常。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.22 21:25:06