2

I had this message when I've tried to ng serve, and I don't know what this means and what I should do, someone can help?

Error: node_modules/@angular/router/router.d.ts:54: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 (@angular/router) which declares ActivatedRoute 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.

export declare class ActivatedRoute {

that is my router.d.ts file :

import * as ɵngcc0 from '@angular/core'; export declare classActivatedRoute {

url: Observable<UrlSegment[]>;
params: Observable<Params>;
queryParams: Observable<Params>;
fragment: Observable<string>;
data: Observable<Data>;
outlet: string;
component: Type<any> | string | null;
snapshot: ActivatedRouteSnapshot;
get routeConfig(): Route | null;
get root(): ActivatedRoute;

get parent(): ActivatedRoute | null;
get firstChild(): ActivatedRoute | null;
get children(): ActivatedRoute[];
get pathFromRoot(): ActivatedRoute[];
get paramMap(): Observable<ParamMap>;
get queryParamMap(): Observable<ParamMap>;
toString(): string; }

that is app.module.ts file

> import { NgModule } from '@angular/core';
> import { BrowserModule } from '@angular/platform-browser';
> import { HttpClientModule } from '@angular/common/http';

> import { AppRoutingModule } from './app-routing.module'; 
> import { AppComponent } from './app.component';
> import { FooterComponent } from'./footer/footer.component'; 
>import { NavbarComponent } from './navbar/navbar.component'; 
>import { ProductsComponent } from './products/products.component';
> import { ProductListComponent } from './product-list/product-list.component';
> import { SideBarComponent } from './side-bar/side-bar.component';
> import { UserComponent } from './user/user.component';
> import { HomeComponent } from './home/home.component';
> import { LoginComponent } from './login/login.component';
> import { CartComponent } from './cart/cart.component';
> import { ContactsComponent } from'./contacts/contacts.component';
> import { PageNotFoundComponent } from './page-not-found/page-not-found.component';
> import { FormsModule, ReactiveFormsModule } from '@angular/forms';
> import { SignupComponent } from './signup/signup.component';
> import { ProductDetailsComponent } from './product-details/product-details.component';
> import { ActivatedRoute } from '@angular/router';

> @NgModule({   declarations: [
>     AppComponent,
>     FooterComponent,
>     NavbarComponent,
>     ProductsComponent,
>     ProductListComponent,
>     SideBarComponent,
>     UserComponent,
>     HomeComponent,
>     LoginComponent,
>     CartComponent,
>     ContactsComponent,
>     PageNotFoundComponent,
>     SignupComponent,
>     ProductDetailsComponent,   ], 
>  imports: [
>     BrowserModule,
>     AppRoutingModule,
>     FormsModule,
>     ReactiveFormsModule,
>     ActivatedRoute,
>     HttpClientModule,   ],   
>providers: [],  
> bootstrap: [AppComponent] })

export class AppModule { }

diana
  • 23
  • 1
  • 1
  • 5
  • could you include more code in your question? specifically the `app.module.ts file?` most likely the error comes from how you are doing the imports of your modules or components – chris Feb 03 '22 at 15:39
  • i don't see any error in your imports but this could help since there could be multiple scenarios https://stackoverflow.com/a/69793983/4957620 – chris Feb 03 '22 at 15:56

1 Answers1

1

Activated Route is not a module, it is a service. You have to remove from the imports. You can use it anyway as you're already adding a routing module.

KSoze
  • 141
  • 3