Module has no exported member 'CanActivate' in Angular

Issue

I am working on a full stack development using Angular, Node.js and MySQL. I am trying to add a route guards in my auth-guard.service.ts file but, when I try to import CanActivate from @angular/core, it gives an error.

 Module '"../../../../node_modules/@angular/core/core"' has no exported member 'CanActivate'.

Here is my code:

admin-layout.routing.ts

import { Routes } from '@angular/router';
import { DashboardComponent } from '../../pages/dashboard/dashboard.component';
import { UserComponent } from '../../pages/user/user.component';
import { TableComponent } from '../../pages/table/table.component';
import { IconsComponent } from '../../pages/icons/icons.component';

export const AdminLayoutRoutes: Routes = [
{ path: 'dashboard',      component: DashboardComponent },
{ path: 'user',           component: UserComponent },
{ path: 'table',          component: TableComponent },
{ path: 'icons',          component: IconsComponent }
];

auth-guard.service.ts

import { CanActivate } from '@angular/core';  //gives an error here
export class AuthGuard implements CanActivate
{
  ....
}

Solution

You are looking in the wrong place.

enter image description here

Answered By – Numichi

Answer Checked By – Mildred Charles (AngularFixing Admin)

Leave a Reply

Your email address will not be published.