我想将我的基于 Ionic Framework 的 Angular 应用升级到 Angular 8.x。
- 是否有升级 Ionic Apps 的官方指南?
- ionic CLI 在升级过程中是否支持开发人员(如 Angular CLI)?
- 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/