Right from the angular docs

You can use this method to prevent accidental loading of a previously loaded module..

How can I tell if a module or service was previously loaded?

Some modules and its services should only be loaded once by the root AppModule. Importing the module a second time by lazy loading a module could produce errant behavior that may be difficult to detect and diagnose.

We can guard against that danger by writing a constructor that attempts to inject the module or service from the root app injector. If the injection succeeds, the class has been loaded a second time. We can throw an error or take other remedial action.

Certain Angular modules (such as BrowserModule) implements such a guard as does this Angular Module chapter sample’s CoreModule constructor.

app/core/core.module.ts
constructor (@Optional() @SkipSelf() parentModule: CoreModule) {
 if (parentModule) {
 throw new Error(
 'CoreModule is already loaded. Import it in the AppModule only');
 }
}