Ionic v4项目创建咨询:已升级CLI后依赖版本疑问
Hey there! I see you've got Ionic CLI v4.0.0-rc.5 installed, but your new blank project is still pulling in Angular 5 dependencies—let's sort this out right away.
The main issue here is almost certainly cached old templates from earlier Ionic v4 beta/RC builds that were tied to Angular 5. Here's how to fix it step by step:
Force a clean template fetch when creating the project
Instead of the standardionic startcommand, add the--cleanflag to make the CLI bypass cached templates and pull the latest ones matching your CLI version:ionic start newproj blank --cleanManually specify the matching template version (if clean mode fails)
Explicitly link to the@ionic/angular-templatespackage that aligns with your CLI version to guarantee compatibility:ionic start newproj blank --type=angular --template=@ionic/angular-templates@4.0.0-rc.5Reset your global Ionic installation (for persistent cache issues)
If the above steps don't work, wipe the global setup and cache entirely:- Uninstall the global Ionic CLI:
npm uninstall -g ionic - Clear your npm cache to remove leftover cached packages:
npm cache clean --force - Reinstall the RC.5 version:
npm install -g ionic@4.0.0-rc.5 - Create your project again using the
--cleanflag from the first step.
- Uninstall the global Ionic CLI:
After following these steps, check your project's package.json—you should see @ionic/angular at version 4.0.0-rc.5 and Angular dependencies (like @angular/core) at version 6.x (e.g., 6.1.10), which is the correct pairing for Ionic v4 RC.5.
内容的提问来源于stack exchange,提问作者krv

