Paulius Papaurėlis
Paulius Papaurėlis

Reputation: 31

Cannot find module angular 8

I'm trying to build multiple apps on one project in Angular 8, but I have problem with finding modules. It's seems that path is good, but I'm still getting error 'Cannot find module'. Tried to put full path, but it does not worked either. My files structure: My files structure

My app.module.ts file My app.module.ts file

My app.routing.ts file

import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home';
import { LoginComponent } from './login';
import { AuthGuard } from './helpers';

const routes: Routes = [
{ path: '', component: HomeComponent, canActivate: [AuthGuard] },
{ path: 'login', component: LoginComponent },


{ path: '**', redirectTo: '' }
];

export const appRoutingModule = RouterModule.forRoot(routes);

Is it possible that I have this problem because of multiple apps in one project, or is the problem somewhere else?

Upvotes: 0

Views: 2196

Answers (2)

Eweren
Eweren

Reputation: 277

  1. I guess you have to change the path of the routing module to app-routing.module
  2. You cannot import the other files without referencing the files direct path. So for HomeComponent it would be . /home/home.component The same for your interceptors and pipes. You cannot reference the path to its directories, if there is not an index.ts file which exports the directories content

Upvotes: 1

GameCoder007
GameCoder007

Reputation: 73

I think you are building multiple project by using ng g application, otherwise you can easily build multiple app in one project by using ng g application

Then you need to export the module in App Module to get that module in child module.

If this is not a solution then plz provide the App routing module

Upvotes: 0

Related Questions