ionic-app-upgrades
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseIonic App Upgrade
Ionic应用升级
Upgrade an Ionic Framework app to a newer major version (4 to 5, 5 to 6, 6 to 7, or 7 to 8).
将Ionic Framework应用升级到更高主版本(4到5、5到6、6到7或7到8)。
Prerequisites
前置条件
| Target Version | Angular | React | Vue |
|---|---|---|---|
| 5 | 8.2+ | 16+ | N/A |
| 6 | 12+ | 17+ | 3.0.6+ |
| 7 | 14+ | 17+ | 3.0.6+ |
| 8 | 16+ | 17+ | 3.0.6+ |
| 目标版本 | Angular | React | Vue |
|---|---|---|---|
| 5 | 8.2+ | 16+ | 不适用 |
| 6 | 12+ | 17+ | 3.0.6+ |
| 7 | 14+ | 17+ | 3.0.6+ |
| 8 | 16+ | 17+ | 3.0.6+ |
Procedures
操作步骤
Step 1: Detect Current Version
步骤1:检测当前版本
Read , , or version from ( or ). Determine the current major version and which framework is in use (Angular, React, Vue, or Core/Standalone).
@ionic/angular@ionic/react@ionic/vuepackage.jsondependenciesdevDependenciesAsk the user for the target version. Default to the latest (8) if not specified.
从的或中读取、或的版本,确定当前主版本以及使用的框架(Angular、React、Vue或Core/独立版本)。
package.jsondependenciesdevDependencies@ionic/angular@ionic/react@ionic/vue询问用户目标版本,若未指定则默认使用最新版本(8)。
Step 2: Execute Upgrade
步骤2:执行升级
For each major version jump between the current and target version, apply the corresponding upgrade guide sequentially:
| Current to Target | Reference |
|---|---|
| 4 to 5 | |
| 5 to 6 | |
| 6 to 7 | |
| 7 to 8 | |
For multi-version jumps (e.g., 5 to 8), apply each upgrade in order:
- Read and apply
references/upgrade-v5-to-v6.md - Build the project (), fix any errors, and verify the app runs
npm run build - Read and apply
references/upgrade-v6-to-v7.md - Build the project (), fix any errors, and verify the app runs
npm run build - Read and apply
references/upgrade-v7-to-v8.md - Build the project (), fix any errors, and verify the app runs
npm run build
Do not skip intermediate versions.
对于当前版本到目标版本之间的每一个主版本跳转,按顺序应用对应的升级指南:
| 当前到目标版本 | 参考文档 |
|---|---|
| 4到5 | |
| 5到6 | |
| 6到7 | |
| 7到8 | |
对于跨多版本跳转的场景(例如5到8),按顺序执行每一次升级:
- 读取并应用的内容
references/upgrade-v5-to-v6.md - 构建项目(),修复所有报错,验证应用可正常运行
npm run build - 读取并应用的内容
references/upgrade-v6-to-v7.md - 构建项目(),修复所有报错,验证应用可正常运行
npm run build - 读取并应用的内容
references/upgrade-v7-to-v8.md - 构建项目(),修复所有报错,验证应用可正常运行
npm run build
不得跳过中间版本。
Step 3: Final Verification
步骤3:最终验证
After completing all upgrade steps:
bash
npm run buildIf the project uses Capacitor, also run:
bash
npx cap sync完成所有升级步骤后执行:
bash
npm run build如果项目使用Capacitor,还需运行:
bash
npx cap syncError Handling
错误处理
- If fails after an upgrade step, check the compiler errors. Most errors are caused by removed component properties, renamed CSS variables, or changed event handler signatures documented in the reference files.
npm run build - If Jest or unit tests fail, check the configuration — Ionic 6+ ships as ES Modules and requires Babel/Jest configuration updates.
transformIgnorePatterns - If CSS styles break after upgrade, check for removed CSS Shadow Parts and renamed CSS variables in the reference file for that version.
- If a multi-version upgrade fails mid-way, fix the current version step before proceeding to the next.
- If the project also uses Capacitor and platform builds fail, the Capacitor version may also need upgrading — use the skill.
capacitor-app-upgrades
- 如果执行升级步骤后失败,检查编译器报错,大部分错误是由参考文档中记录的组件属性移除、CSS变量重命名或事件处理函数签名变更导致的。
npm run build - 如果Jest或单元测试失败,检查配置——Ionic 6+以ES Modules形式发布,需要更新Babel/Jest配置。
transformIgnorePatterns - 如果升级后CSS样式损坏,检查对应版本参考文档中已移除的CSS Shadow Parts和重命名的CSS变量。
- 如果跨多版本升级中途失败,先修复当前版本步骤的问题再继续下一个版本的升级。
- 如果项目同时使用Capacitor且平台构建失败,可能也需要升级Capacitor版本——使用技能处理。
capacitor-app-upgrades
Related Skills
相关技能
- — If Capacitor also needs upgrading alongside Ionic, use this skill for the Capacitor-specific upgrade steps.
capacitor-app-upgrades - — General Ionic development guidance.
ionic-app-development - — For installing or reconfiguring plugins after the app upgrade.
capacitor-plugins
- —— 如果需要同时升级Ionic和Capacitor,使用该技能处理Capacitor专属的升级步骤。
capacitor-app-upgrades - —— 通用Ionic开发指导。
ionic-app-development - —— 用于应用升级后安装或重新配置插件。
capacitor-plugins