How to Create a specific version of an Ionic Project using the CLI?

461 views Asked by At

I need to create different Ionic-Angular projects, with different versions of the Ionic and Angular core, that specifically run on different versions of Node:

For example:

Node V. Angular V. Angular Release date Ionic V.
12.16.x 11.0.0 2020-11-11 5
14.20.x 15.2.0 2023-02-23 6
16.14.x 16.2.0 2023-06-13 7

To achieve this with Angular projects, what I normally do is, Using NVM I select the version of Node I need, install the corresponding Angular CLI (globally), and then create a new project, as follows:

nvm use 12.16 npm i -g @angular/cli@12 ng new Angular12Node12Project

But my problem is that the Ionic CLI doesn't work the same way, and I don't know how to solve it.

So my idea was to solve it by replicating the same behavior, like this:

nvm use 12.16 npm i -g @ionic/cli@5 ng start Ionic5Node12Project

but when running 'npm i -g @ionic/cli@5' it gives me the following error.

npm ERR! code ETARGET
npm ERR! notarget No matching version found for @ionic/cli@5.
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
1

There are 1 answers

1
0urz4g On

The ionic cli package has changed after version 6.

For versions 6 and after, use

npm install @ionic/cli

lists of releases

For versions 5 and before, use

npm install ionic

lists of releases

May be you will find the exact version you need with the old package.

For anyone that reads this page, notice that the latest version @ionic/cli can be used to create Ionic projects for version 1, 3 and 7. The old version "ionic" is not supposed to be used anymore.