简体   繁体   English

将 angular 6 升级到 9 的最佳方法是什么?

[英]What is the best way to upgrade angular 6 to 9?

Currently, my project is running in angular 6, I have to upgrade it in angular 9 now so what is the best way to upgrade?目前,我的项目在 angular 6 运行,我现在必须在 angular 9 升级它,那么最好的升级方式是什么? which is the main point to focus on when we upgrade it?我们升级的时候要重点关注哪一点呢? Share your knowledge分享你的知识

This is the best doc you can follow as of today from angular:)这是您今天可以从 angular 关注的最佳文档:)

https://update.angular.io/#6.0:9.0 https://update.angular.io/#6.0:9.0

with a warning from angular来自 angular 的警告

Warning: We do not recommend moving across multiple major versions.警告:我们不建议跨多个主要版本。

You need to focus on these after conversion to make it work -转换后你需要关注这些以使其工作 -

  1. Rxjs version may change which may break your code Rxjs 版本可能会更改,这可能会破坏您的代码
  2. I don't remember HttpClient was present in angular 6, if not you should replace your import in app.module for Http calls我不记得 HttpClient 出现在 angular 6 中,如果没有,您应该替换 app.module 中的导入以进行 Http 调用
  3. Update all your packages that should support angular 9更新所有应该支持 angular 9 的包
  4. If you are using lazy loading the way it should be called in app.routing.ts changes now in angular 9 compared to angular 6如果您正在使用延迟加载,那么在 angular 9 与 angular 6 相比,现在应该在 app.routing.ts 中调用它的方式发生了变化

You can use this to update all your packages to the latest version您可以使用它来将所有包更新到最新版本

npm i -g npm-check-updates
ncu -u
npm install

Note: I may miss some points sorry for that.注意:我可能会遗漏一些要点,对此深表歉意。 These are what I remember as of now:)这些是我现在记得的:)

You should follow the official upgrade guide: https://update.angular.io/#6.0:9.0l3 .您应该遵循官方升级指南: https://update.angular.io/#6.0:9.0l3

There are quite a few steps involved as shown on that page.如该页面所示,涉及很多步骤。 Chances are, you will run into issues as you perform the steps.很有可能,您在执行这些步骤时会遇到问题。 Google or post separate questions for each issue as you encounter them.当您遇到每个问题时,谷歌或发布单独的问题。 Good thing is, many of upgrade issues have been posted and solved, which should make it a little easier.好消息是,许多升级问题都已发布并得到解决,这应该会更容易一些。

You might run into issues with dependency versions, and might stick to version 8 for the time being, until all of your dependencies are updated.您可能会遇到依赖版本的问题,并且可能会暂时坚持使用版本 8,直到更新所有依赖项。

Good luck!祝你好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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