I am trying to upgrade my nativescript application to use the new Angular Router, however, I get the following error message:
java.lang.RuntimeException: Unable to create application com.tns.NativeScriptApplication: com.tns.NativeScriptException: Failed to find module: "@angular/router/common_router_providers", relative to: /app/tns_modules/
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4710)
at android.app.ActivityThread.-wrap1(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1405)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Caused by: com.tns.NativeScriptException: Failed to find module: "@angular/router/common_router_providers", relative to: /app/tns_modules/
at com.tns.Module.resolvePathHelper(Module.java:220)
at com.tns.Module.resolvePath(Module.
in my main.ts I have:
import {nativeScriptBootstrap} from "nativescript-angular/application";
import {AppComponent} from "./app.component";
import {APP_ROUTER_PROVIDERS} from "./app.routes";
nativeScriptBootstrap(AppComponent, [APP_ROUTER_PROVIDERS]);
then in my app.routes.ts I have:
import {RouterConfig} from '@angular/router';
import {nsProvideRouter} from "nativescript-angular/router";
import {HomePage} from "./Components/Home/home.component";
import {Bottles} from "./Components/BottleList/bottleList.component";
const routes: RouterConfig = [
{ path: "", redirectTo: "/home", terminal: true },
{ path: "home", component: HomePage },
{ path: "bottles", component: Bottles },
];
export const APP_ROUTER_PROVIDERS = [
nsProvideRouter(routes, {enableTracing: false })
];
then my app.component.ts:
import {Component, OnInit} from "@angular/core";
import {NS_ROUTER_DIRECTIVES} from "nativescript-angular/router";
@Component({
selector: "main",
directives: [NS_ROUTER_DIRECTIVES],
template: "<page-router-outlet></page-router-outlet>"
})
export class AppComponent implements OnInit {
page: Page;
}
Any ideas what I have done wrong?
Update:
I am using -
- tns-android: 2.1.1
- @angular/common: 2.0.0-rc.4
- @angular/router: 3.0.0-beta.2
- nativescript-angular: 0.2.0
- tns-core-modules: 2.1.0
- nativescript (global): 2.1.1
- node (global): 4.4.7
-rc.4and I tried using@angular/[email protected]but I got the same result ... - George Edwards