Property 'forRoot' does not exist on type 'typeof NgxJsonLdModule'

18,192

Solution 1

This specific package (sources here) does not provide any service, so it doesn't need a forRoot method on the import.

You can just import it like this :

@NgModule({
  declarations: [AppComponent],
  imports: [
     AppRoutingModule,
     NgtUniversalModule,
     NgxJsonLdModule
  ],
  providers: []
})
export class AppModule {}

Solution 2

By looking here :

https://github.com/coryrylan/ngx-json-ld/blob/master/lib/ngx-json-ld.module.ts

seems like there is not .forRoot() method defined for that module, so as previous comment says correct, you can just add the module and thats it!

Good luck!

Share:
18,192

Related videos on Youtube

GeoffreyMahugu
Author by

GeoffreyMahugu

Updated on June 04, 2022

Comments

  • GeoffreyMahugu
    GeoffreyMahugu almost 2 years

    I have installed this package @ngx-lite/json-ld. In an attempt to make my SEO schema.org dynamic. On importing the module as specified on this Tutorial I get this error:

    ERROR in src/app/app.module.ts(18,21): error TS2339: Property 'forRoot' does not exist on type 'typeof NgxJsonLdModule'.

    Here is my app.module

    import { NgtUniversalModule } from "@ng-toolkit/universal";
    import { BrowserModule } from "@angular/platform-browser";
    import { NgModule } from "@angular/core";
    
    // Third Party library
    import { NgxJsonLdModule } from "@ngx-lite/json-ld";
    
    import { AppComponent } from "./app.component";
    import { AppRoutingModule } from "./app-routing.module";
    @NgModule({
      declarations: [AppComponent],
      imports: [
         AppRoutingModule,
         NgtUniversalModule,
         NgxJsonLdModule.forRoot()
      ],
      providers: []
    })
    export class AppModule {}
    

    I'm using angular 6.1.9 and Angular Universal.