Reputation: 9457
How do I update Angular 2 version? I use Angular CLI 1.0.0-beta.20-4 and I tried npm update --save but it does not do anything.
Below is my package.json file at the moment. Appreciate any help on this.
{
"name": "todo1",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"start": "ng serve",
"lint": "tslint \"src/**/*.ts\"",
"test": "ng test",
"pree2e": "webdriver-manager update",
"e2e": "protractor"
},
"private": true,
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/material": "^2.0.0-alpha.11-3",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/router": "3.0.0",
"@types/hammerjs": "^2.0.33",
"@types/lodash": "^4.14.43",
"angular2-jwt": "^0.1.25",
"angular2-uuid": "^1.1.0",
"core-js": "^2.4.1",
"hammerjs": "^2.0.8",
"lodash": "^4.17.2",
"material-design-icons": "^3.0.1",
"rxjs": "5.0.0-beta.12",
"ts-helpers": "^1.1.1",
"zone.js": "^0.6.23"
},
"devDependencies": {
"@types/hammerjs": "^2.0.33",
"@types/jasmine": "^2.2.30",
"angular-cli": "^1.0.0-beta.20-4",
"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.5",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "2.0.2"
}
}
Upvotes: 6
Views: 3005
Reputation: 11525
You can change the @angular versions to use a caret range so NPM will install the latest package up to the next major release.
"dependencies": {
"@angular/common": "^2.2.1",
"@angular/compiler": "^2.2.1",
"@angular/core": "^2.2.1",
"@angular/forms": "^2.2.1",
"@angular/http": "^2.2.1",
Also it would be worth updating to the latest angular-cli version. See here for instructions.
Upvotes: 5
Reputation: 5107
The main issue you have here is that npm update will only update to the latest compatible version of each module with a limit of the highest version specified in the package.json.
The safest way to do this is to update your package.json to have a wildcard for the minor and patch sections. Angular 2 (as opposed to angular 1) uses semVer (http://semver.org/) so you can safely wildcard the minor and patch parts.
"@angular/common": "2.*.*",
"@angular/compiler": "2.*.*",
"@angular/core": "2.*.*",
"@angular/forms": "2.*.*",
"@angular/http": "2.*.*",
"@angular/material": "^2.0.0-alpha.11-3",
"@angular/platform-browser": "2.*.*",
"@angular/platform-browser-dynamic": "2.*.*",
"@angular/router": "3.0.0",
Run npm update / npm install again and you should upgrade.
Upvotes: 1