Angular 运行ng serve时出现ng翻译错误

Angular 运行ng serve时出现ng翻译错误,angular,ngx-translate,Angular,Ngx Translate,我正在做ngx翻译。运行我的实现代码会在ng serve上引发以下错误 rror: node_modules/@ngx-translate/http-loader/lib/http-loader.d.ts:4:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class. This likely means that t

我正在做ngx翻译。运行我的实现代码会在ng serve上引发以下错误

rror: node_modules/@ngx-translate/http-loader/lib/http-loader.d.ts:4:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.       

This likely means that the library (@ngx-translate/http-loader) which declares TranslateHttpLoader has not been processed correctly by ngcc, or is not compatible with Angular Ivy. Check if 
a newer version of the library is available, and update if so. Also consider checking with the library's authors to see if the library is expected to be compatible with Ivy.

4 export declare class TranslateHttpLoader implements TranslateLoader {
在节点_模块http-loader.d.ts中,类TranslateHttpLoader也带有下划线

export declare class TranslateHttpLoader implements TranslateLoader {
    private http;
    prefix: string;
    suffix: string;
    constructor(http: HttpClient, prefix?: string, suffix?: string);
    /**
     * Gets the translations from the server
     */
    getTranslation(lang: string): Observable<Object>;
}
我使用:

节点:12.19.0

角度:11.2.13

ngx翻译/核心:13.0.0

ngx翻译/http加载程序:6.0.0


有什么问题,有什么想法吗?

您需要从导入的
NgModule
数组中删除
TranslateHttpLoader
。也许你加错了。
谢谢

尝试运行命令“npmci”,谢谢您的评论!但它无法解决此问题。请添加您的AppModule.ts您使用的是哪个版本的
ngx translate
?错误是该库可能与Angular 11中默认启用的Ivy不兼容。是的,删除TranslateHTTPLoader修复了该问题。不知道我何时以及为什么将此添加到imports数组。请把你的答案贴出来,我会在上面签名的!
import { HttpClient, HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

export function createTranslateLoader(http: HttpClient) {
  return new TranslateHttpLoader(http, './assets/i18n/', '.json');
}

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    HttpClientModule,
    TranslateHttpLoader,
    TranslateModule.forRoot(
      {
        loader: {
          provide: TranslateLoader,
          useFactory: (createTranslateLoader),
          deps: [HttpClient]
        },
        defaultLanguage: 'en'
      }
    ),
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }