简体   繁体   中英

What is the correct method for upgrading Angular Project from V2 -> V7?

I am tasked with upgrading a medium Angular V2.0.1 project to Angular V7.1.4 (latest stable version). I have worked with Angular a lot in the past and upgraded from V2 -> V4 and V4 -> V5 for a different Angular project in the past. These upgrades were not always trivial and had breaking changes. After doing some research I stumbled upon the Angular Upgrade Guide ( https://update.angular.io/ ) which seems like a good place to start. I also stumbled upon ( Upgrading Angular 2 to Angular 6 ) and in the comments someone says I should start a new project using Angular CLI and move the code over manually.

Another thing to note is that the 2.0.1 project uses systemjs (because it was created from the original Angular Quickstart). Ideally we would make the switch over to webpack.

Should I create a new project using Angular CLI and copy the code over and try to fix bugs that way or should I follow the Angular Update Guide and stay within the same project?

I do not recommend you jump from v2 to v7. You should go from v2 to v5 and update to v7. Making sure the project is stable before proceeding to the next update.

There is an online tool to assist you in updating.

https://update.angular.io/

The ng update tool requires that the project is using an up to date angular.json file for configuration. It is far easier to create one via a new project than to create one manually. I don't think this file was introduced until Angular 5.

You can use the above website as a guide to update to v5, but the update is going to require that you manually update the source code. Once you are at a stable v5 you can run the ng update tool and it will automate some of the upgrade process for you.

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM