angular - Ionic 4 与 Angular : Any Upgrade Guidelines available?

标签 angular ionic-framework upgrade

我想将我的基于 Ionic Framework 的 Angular 应用升级到 Angular 8.x。

  1. 是否有升级 Ionic Apps 的官方指南?
  2. ionic CLI 在升级过程中是否支持开发人员(如 Angular CLI)?
  3. ionic 框架是否支持 ng update

当前版本:

下面的输出由 ionic info 生成(在项目文件夹中执行):

ionic :

   Ionic CLI                     : 5.4.1 (C:\ProgramData\nvm\v10.15.0\node_modules\ionic)
   Ionic Framework               : @ionic/angular 4.9.0
   @angular-devkit/build-angular : 0.13.8
   @angular-devkit/schematics    : 7.3.8
   @angular/cli                  : 7.3.8
   @ionic/angular-toolkit        : 1.5.1

Cordova :

   Cordova CLI       : 9.0.0 (<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7c1f130e18130a1d5110151e3c45524c524d" rel="noreferrer noopener nofollow">[email protected]</a>)
   Cordova Platforms : android 8.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.1.3, cordova-plugin-ionic-webview 4.0.1, (and 8 other plugins)

实用程序:

   cordova-res : not installed
   native-run  : 0.2.8

系统:

   NodeJS : v10.15.0 (C:\Program Files\nodejs\node.exe)
   npm    : 6.4.1
   OS     : Windows 10

感谢您的帮助!

最佳答案

这是将 Ionic 4 升级到 Angular 8 的半官方指南(由 Ionic 团队的 Mike Hartington 发布): https://docs.google.com/document/d/1QOpQeDifPSg6F9WycDLcbQnpqjN96ew-Ap0_CB7CcCQ

我刚刚尝试了一下,效果非常好。

Updating Ionic to Angular 8

Update @ionic/angular and @ionic/angular-toolkit to the latest release

npm install @ionic/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="01606f66746d607341352f362f31" rel="noreferrer noopener nofollow">[email protected]</a>
npm install @ionic/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f3929d94869f9281de879c9c9f989a87b3c1ddc3ddc3" rel="noreferrer noopener nofollow">[email protected]</a> -D

From here we can run the following commands

npx ng update @angular/core @angular/cli

Now most packages should be updated, just to be sure, we also need to update these

Install the latest angular devkit updates with

npm i @angular-devkit/architect@latest @angular-devkit/build-angular@latest @angular-devkit/core@latest @angular-devkit/schematics@latest

Or if you’re on a mac/linux

npm i @angular-devkit/{architect,build-angular,core,schematics}@latest

Potential Issues
There is a known bug in an older version of the Angular CLI that will cause the update commands to stop running and exit. If you encounter this, please look over this issue and use the commands below.

https://github.com/angular/angular-cli/issues/14589

npx ng update @angular/core
npx ng update --allow-dirty @angular/core --from 7 --to --migrate-only

ng update @angular/cli --allow-dirty
ng update @angular/cli --allow-dirty --from 7 --to 8 --migrate-only

There is a known bug where the Angular CLI will attempt to install Angular 8.2.0-next. If you encounter this, please look over this issue and use the commands below:

https://github.com/angular/angular-cli/issues/14980

npm install @angular/cli@latest
npx ng update @angular/core

Notice that this has you updating the Angular CLI first, then updating Angular Core. From here, you can continue on with the remaining commands in the guide above.

If you encounter any problems, please open a new issue on the Ionic repo with detailed steps to reproduce: https://github.com/ionic-team/ionic/issues

关于angular - Ionic 4 与 Angular : Any Upgrade Guidelines available?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58505914/

相关文章:

Angular CLI - 为现在部署设置生产代理

android - HTML 5 视频标签,使用 Ionic 3 在 Android 上 2-4 秒后开始播放视频

c# - 如何防止Visual Studio提示将项目.NET 4升级到.NET 4.5

angular - 如何将 Angular 表单验证与 ngFor 绑定(bind)

css - 如何在此代码段中正确使用 CSS 过渡属性?

angular - 在angular2中动态加载HTML模板

ionic-framework - Ionic 2/4 Infinite Scroll 向上...而不是向下,用于聊天应用程序。奇怪的间距和奇怪的行为

css - 为什么我的媒体查询没有改变这个元素的背景颜色?

从mysql 4.1升级到mysql 5.5

jquery - 从 jQuery 1.x 升级到 jQuery 2.x