Reputation: 1096
I working on ngx-translate. Running my implemented code fires the following error on 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 {
In node_modules http-loader.d.ts the class TranslateHttpLoader is also underlined.
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>;
}
This is my AppModule:
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 { }
I use:
node: 12.19.0
Angular: 11.2.13
ngx-translate/core: 13.0.0
ngx-translate/http-loader: 6.0.0
What’s the problem, are there any ideas out there?
Upvotes: 4
Views: 5142
Reputation: 985
You need to remove TranslateHttpLoader
from your import array of NgModule
. Maybe you added it by mistake.
Thanks!
Upvotes: 3