2
votes

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.

3

3 Answers

6
votes

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 {}
1
votes

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!

0
votes

maybe change .forRoot by .withConfig

@NgModule({
  imports: [
    ...
    NgxMapboxGLModule.withConfig({
      accessToken: 'TOKEN', // Optional, can also be set per map (accessToken input of mgl-map)
      geocoderAccessToken: 'TOKEN' // Optional, specify if different from the map access token, can also be set per mgl-geocoder (accessToken input of mgl-geocoder)
    })
  ]
})