[英]Updating applications on Angular from 4 to 5 versions
I have an application written in Angular 4. 我有一个用Angular 4编写的应用程序。
package.json: package.json:
{
"name": "frontend",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"build-bundle-report": "ng build --prod --stats-json && webpack-bundle-analyzer dist/stats.json",
"bundle-report": "webpack-bundle-analyzer dist/stats.json"
},
"private": true,
"dependencies": {
"@angular/animations": "^4.1.3",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@ngui/datetime-picker": "^0.16.2",
"angular2-modal": "^3.0.1",
"angular2-text-mask": "^8.0.1",
"core-js": "^2.4.1",
"flexboxgrid": "^6.3.1",
"moment": "^2.18.1",
"ng-select": "^1.0.0-beta.5",
"ng2-pagination": "^2.0.2",
"ng2-toastr": "^4.1.0",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
},
"devDependencies": {
"@angular/cli": "^1.2.7",
"@angular/compiler-cli": "^4.0.0",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@ngui/datetime-picker": "^0.16.2",
"angular2-modal": "^3.0.1",
"angular2-text-mask": "^8.0.1",
"core-js": "^2.4.1",
"flexboxgrid": "^6.3.1",
"moment": "^2.18.1",
"ng-select": "^1.0.0-beta.5",
"ng2-pagination": "^2.0.2",
"ng2-toastr": "^4.1.0",
"rxjs": "^5.1.0",
"zone.js": "^0.8.4"
}
}
How can it be updated to Angular 5 without damaging the code? 如何在不损坏代码的情况下将其更新到Angular 5? The last time I tried to update it some of the code stopped working. 我上次尝试对其进行更新时,某些代码停止了工作。 I will be very grateful to everyone who will help. 我将非常感谢能为您提供帮助的每个人。
To upgrade your app I recommend this read 要升级您的应用,我建议您阅读以下内容
In a nutshell you should run: 简而言之,您应该运行:
npm install @angular/{animations,common,compiler,compiler-cli,core,forms,http,platform-browser,platform-browser-dynamic,platform-server,router}@5.0.0
You can replace @5.0.0
with any version of 5.x you wanna use. 您可以将@5.0.0
替换为要使用的任何5.x版本。
The other thing you'll need is to update Typescript to 2.4.2 and RxJS to 5.5.2 您需要做的另一件事是将Typescript更新为2.4.2,将RxJS更新为5.5.2。
npm install typescript@2.4.2 rxjs@5.5.2
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.