What is the safest way to recover when an Ionic CLI upgrade fails midway and leaves mixed versions?
0 reputation · 25 Dec 2021, 13:15 UTC
I am planning a global upgrade of the Ionic CLI via npm and want a clear recovery plan in case the upgrade fails partway through. My understanding is that the npm install -g @ionic/cli process is not atomic, so an interrupted install could leave a mixture of old and new CLI files in the global node_modules directory, with no built-in rollback command.
The constraints I am working under: the project pins specific Cordova/Capacitor plugin versions that may be sensitive to CLI version changes, the machine is macOS so global npm permissions matter (I want to avoid sudo if possible), and I need to confirm afterward that exactly one CLI version is installed and that it is compatible with the project's Ionic Framework version.
My specific questions:
- After a failed upgrade, is reinstalling the previous known-good version with
npm install -g @ionic/cli@<version>sufficient, or should the npm and Ionic caches be cleared first to avoid reinstalling corrupted artifacts? - What is the most reliable verification that recovery succeeded — is
ionic infoplusnpm list -g @ionic/clienough, or should a test build be run before trusting the CLI again? - Is there any supported way to make CLI upgrades transactional or at least detect a partial install automatically?