Search code examples
ionic-framework

Problems installing a specific version of Ionic with Node


How can I create a project with ionic 5 using "ionic start". I have Ionic cli version 6.20.8 and Node 16.14.0 and the projects are created with ionic 7.

What I did was to install another version of the cli with "npm install -g [email protected]" but it installs version 6.20.8, the same I tried with the command "ionic start myApp tabs --type=angular --capacitor --version=5.4.16" but it is still created with version 7 of Ionic.


Solution

  • You do not need to use version 5 of Ionic to achieve your goal. In fact, I would recommend against a version 2 releases behind.

    A workaround would be as such:

    1. Create a base angular project npx -p @angular/cli ng new myApp

    2. Go into the newly created project cd myApp

    3. Init the project as an Ionic app npx @ionic/cli init "My App" --type=angular

    This will create a project with the latest and greatest and include the module structure you want. However, it doesn't create the tabs. You will have to add this by hand.

    If you really want to do Ionic 5 and have tabs auto added you can use the old package name and do npx ionic start myApp tabs --type=angular --capacitor

    But speaking from experience, if you are doing any kind of professional work, I strongly recommend that you make the commitment to staying on the latest versions and libraries for the sake of security/bug fixes, build processes, and long-term maintainability.