Pascal
Pascal

Reputation: 12885

Lazy module can not be found although path seems correct

link: https://play.nativescript.org/?template=play-ng&id=Annyna&v=4

error: ERROR Error: Uncaught (in promise): Error: com.tns.NativeScriptException: Failed to find module: "./TrainingUnit", relative to: app/trainingunit/list/

Its odd that the module name in the error message is: "./TrainingUnit"

The module file name is: trainingunit.module

The module class name is: TrainingUnitModule

Both module "names" seem correct.

As I assume there error is in the AppRouterModule:

import { NgModule } from "@angular/core";
import { Routes } from "@angular/router";
import { NativeScriptRouterModule } from "nativescript-angular/router";

const routes: Routes = [
    { path: "", redirectTo: "/trainingunits", pathMatch: "full" },
    { path: "trainingunits", loadChildren: "./trainingunit/list/trainingunit.module#TrainingUnitModule" }
];

@NgModule({
    imports: [NativeScriptRouterModule.forRoot(routes)],
    exports: [NativeScriptRouterModule]
})
export class AppRoutingModule { }

Upvotes: 2

Views: 43

Answers (1)

Teddy Sterne
Teddy Sterne

Reputation: 14221

In the TrainingUnitComponent you are trying to import TrainingUnit from ./TrainingUnit but the file name should should be ./trainingunit. Update to import the class from the correct file and you should be good to go.

trainingunit.component.ts line:2

import TrainingUnit from "./trainingunit";

Upvotes: 1

Related Questions