skip to Main Content

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

Answers


  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 {}
    
    Login or Signup to reply.
  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!

    Login or Signup to reply.
  3. 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)
        })
      ]
    })
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search