Himanshi Gupta
Himanshi Gupta

Reputation: 171

How can I upgrade the version of router in angular 2?

I am currently using this : @angular/[email protected] & I want to upgrade it to @angular/[email protected]. This is my app.routes.ts

import { provideRouter, RouterConfig } from '@angular/router';
import {SubjectsComponent} from './subjects.component';
import {ProfileDetailsComponent} from './profileDetails.component';
import {AgreementComponent} from './agreement.component';

export const routes: RouterConfig = [
 { path: 'subjects', component: SubjectsComponent },
  { path: 'profile', component: ProfileDetailsComponent },
 { path: 'agreement', component: AgreementComponent }
 ];

  export const appRouterProviders = [
  provideRouter(routes)
 ];

I've changed the version of router, changed the the rc.3 to rc.4, still getting the same error. Here's my package.json:

    "dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/forms": "~0.1.0",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
    "@angular/router": "^3.0.0-beta.2",
    "@angular2-material/button": "^2.0.0-alpha.6",
    "@angular2-material/card": "^2.0.0-alpha.6",
    "@angular2-material/checkbox": "^2.0.0-alpha.6",
    "@angular2-material/core": "^2.0.0-alpha.6",
    "@angular2-material/icon": "^2.0.0-alpha.6",
    "@angular2-material/input": "^2.0.0-alpha.6",
    "@angular2-material/list": "^2.0.0-alpha.6",
    "@angular2-material/progress-bar": "^2.0.0-alpha.6",
    "@angular2-material/progress-circle": "^2.0.0-alpha.6",
    "@angular2-material/radio": "^2.0.0-alpha.6",
    "@angular2-material/sidenav": "^2.0.0-alpha.6",
    "@angular2-material/tabs": "^2.0.0-alpha.6",
    "@angular2-material/toolbar": "^2.0.0-alpha.6",
    "core-js": "^2.4.0",
    "reflect-metadata": "0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.26",
    "zone.js": "^0.6.12"
  },

Upvotes: 2

Views: 1080

Answers (2)

pd farhad
pd farhad

Reputation: 6432

Make sure you dont use @angular/router-deprecated anymore in your package.json Update your package.json like this way :)

 "dependencies": {
    "@angular/common": "2.0.0-rc.4",
    "@angular/compiler": "2.0.0-rc.4",
    "@angular/core": "2.0.0-rc.4",
    "@angular/forms": "0.2.0",
    "@angular/http": "2.0.0-rc.4",
    "@angular/platform-browser": "2.0.0-rc.4",
    "@angular/platform-browser-dynamic": "2.0.0-rc.4",
     "@angular/router": "3.0.0-beta.2",
    "es6-shim": "^0.35.0",
    "jquery": "^2.2.4",
    "jquery-ui": "^1.10.5",
    "leaflet": "^0.7.7",
    "moment": "^2.13.0",
    "ng2-bootstrap": "^1.0.17",
    "ng2-slim-loading-bar": "^1.2.3",
    "ng2-toastr": "^0.3.0",
    "reflect-metadata": "0.1.3",
    "rxjs": "5.0.0-beta.6",
    "systemjs": "0.19.26",
    "zone.js": "^0.6.12"
  }

Then do a npm install in your command prompt/terminal

Upvotes: 0

Akshay Rao
Akshay Rao

Reputation: 3544

just go to your package.json and change

--------> "@angular/router": "3.0.0-alpha-7" to "@angular/router": "3.0.0-beta.2",

and then go to terminal and type npm install .

and this will do what you want :)

this is your answer :---

just update your package.json file with the following code

"@angular/common": "2.0.0-rc.4", "@angular/compiler": "2.0.0-rc.4", "@angular/core": "2.0.0-rc.4", "@angular/forms": "0.2.0", "@angular/http": "2.0.0-rc.4", "@angular/platform-browser": "2.0.0-rc.4", "@angular/platform-browser-dynamic": "2.0.0-rc.4", "@angular/router": "3.0.0-beta.1", "@angular/router-deprecated": "2.0.0-rc.2", "@angular/upgrade": "2.0.0-rc.4"

i have tested this and this works fine now :)

Upvotes: 3

Related Questions