has no exported member 'ROUTER_DIRECTIVES' and 'provideRouter' in Angular 2

12,311

Angular 2 is now released. The version is '2.0.0'. In Release Version there are no provideRouter and ROUTER_DIRECTIVES. For routing in Angular 2 Release see Routing and Navigation

Share:
12,311
Sasireka
Author by

Sasireka

Updated on June 05, 2022

Comments

  • Sasireka
    Sasireka almost 2 years

    I have created a new project with angular-cli: 1.0.0-beta.17 node: 4.1.0 npm: 3.10.8

    Package.json:

    "dependencies": {
        "@angular/common": "~2.0.0",
        "@angular/compiler": "~2.0.0",
        "@angular/core": "~2.0.0",
        "@angular/forms": "~2.0.0",
        "@angular/http": "~2.0.0",
        "@angular/platform-browser": "~2.0.0",
        "@angular/platform-browser-dynamic": "~2.0.0",
        "@angular/router": "~3.0.0",
        "core-js": "^2.4.1",
        "rxjs": "5.0.0-beta.12",
        "ts-helpers": "^1.1.1",
        "zone.js": "^0.6.23"
      },
      "devDependencies": {
        "@types/jasmine": "^2.2.30",
        "@types/node": "^6.0.42",
        "angular-cli": "1.0.0-beta.17",
        "codelyzer": "~0.0.26",
        "jasmine-core": "2.4.1",
        "jasmine-spec-reporter": "2.5.0",
        "karma": "1.2.0",
        "karma-chrome-launcher": "^2.0.0",
        "karma-cli": "^1.0.1",
        "karma-jasmine": "^1.0.2",
        "karma-remap-istanbul": "^0.2.1",
        "protractor": "4.0.9",
        "ts-node": "1.2.1",
        "tslint": "3.13.0",
        "typescript": "2.0.2"
      }
    

    I created a new file for router under src/app.The code is:

    import { DirectoryComponent } from "./directory/directory.component";
    import { HomeComponent } from "./home/home.component";
    import { provideRouter } from '@angular/router';
    
    const APP_ROUTES = [
        {path: 'directory', component: DirectoryComponent},
        {path: '', component: HomeComponent}
    ];
    
    export const APP_ROUTES_PROVIDER = [
        provideRouter(APP_ROUTES)
    ];
    

    My main.ts file is:

    import './polyfills.ts';
    
    import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
    import { enableProdMode } from '@angular/core';
    import { environment } from './environments/environment';
    import { AppModule } from './app/';
    import { APP_ROUTES_PROVIDER } from "./app/app.route";
    
    if (environment.production) {
      enableProdMode();
    }
    
    platformBrowserDynamic().bootstrapModule(AppModule,[APP_ROUTES_PROVIDER]);
    

    While running the code I am getting the error:

    ERROR in [default] /home/newAngularTwo/src/app/app.component.ts:3:9 
    Module '"/home/sasireka/newAngularTwo/node_modules/@angular/core/index"' has no exported member 'ROUTER_DIRECTIVES'.
    
    ERROR in [default] /home/newAngularTwo/src/app/app.route.ts:3:9 
    Module '"/home/sasireka/newAngularTwo/node_modules/@angular/router/index"' has no exported member 'provideRouter'.
    

    What is the mistake I am making? Thanks in advance.