Switching the installation of Ionic from version Ionic 1 to Ionic 2 is very time consuming work.
We have some projects made using Ionic 1 and some using Ionic 2. Installing again and again ionic versions create problems.Using nvm (node version manager)it became very easy to perform this switching.
Firstly open terminal and create ionic 1 and ionic 2 applications using the commands:
ionic start helloionic1 blank //////////for ionic 1
ionic start helloionic2 blank --v2 --ts ////////// for ionic 2
Then go into the application and create file with name .nvmrc in both the application . Check the versions of nvm using the below command in terminal:
nvm ls-remote
This command will give you the list of nvm versions available. Select nvm versions which you wants for your applications. Lets take an example , for ionic 1 select the nvm v5.0.0 and for ionic 2 nvm v6.4.0.
Mention the nvm versions in both the .nvmrc files respectively of applications.Then through terminal install the selected versions of nvm in the applications using the command:
nvm install v5.0.0 ///////for ionic 1
nvm install v6.4.0 ////// for ionic 2
After completion of the installation check the version of npm by using the below command as with nvm, npm is installed automatically :
npm -v
But before this execute the command nvm use in terminal so that npm can use the nvm. In both the application the version of npm should be different.
After this we are almost done just have to install ionic1 and ionic2 in the applications helloionic1 and helloionic2 respectively using the commands:
npm install -g ionic@1.7.15 ////////for ionic 1
npm install -g ionic @beta //////// for ionic 2
Now you can run both ionic versions on your system in different applications
Commands for ionic 1
ionic start helloionic1 blank
cd helloionic1
nvm install v5.0.0
nvm use
npm -v
npm install -g ionic@1.7.15
Commands for ionic 2
ionic start helloionic2 blank --v2 --ts
cd helloionic2
nvm install v6.4.0
nvm use
npm -v
npm install -g ionic@6.4.0
Note: This will be applicable if you are already having nvm and any version of ionic in your system, if not then see below steps
Step 1: Install nvm using the below command:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.6/install.sh | bash
This will install the the nvm in your system.
Step 2: Then create 2 folders one for ionic1 and other for ionic2.
Step 3: Create .nvmrc files in both the folder and write the text 5.0.0 and 6.4.0 in ionic1 and ionic2 folders respectively as we get these versions of nvm by using the command:
nvm ls-remote
Step 4: After this install nvm versions using the below commands and check the version of the nvm using the command nvm -v it will be different for both :
nvm install v5.0.0 ///////for ionic 1
nvm install v6.4.0 ////// for ionic 2
Step 5: Now execute the nvm use command and install the ionic 1 and ionic 2 frameworks in respective folders using the commands:
npm install -g ionic@1.7.15 ////////for ionic 1
npm install -g ionic @beta //////// for ionic 2
Step 6: Now the last step is to create applications of ionic1 and ionic2 frameworks in respective folders using the command:
ionic start helloionic1 blank //////////for ionic 1
ionic start helloionic2 blank --v2 --ts ////////// for ionic 2
Now you can go into the application and can run the application using the command ionic serve.
Summary
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.6/install.sh | bash ////nvm install
nvm ls-remote
For ionic 1
cd ionic1
nvm use
nvm install v5.0.0
npm install -g ionic@1.7.15
ionic start helloionic1 blank
cd helloionic1
ionic serve
For ionic 2
cd ionic2
nvm use
nvm install v6.4.0
npm install -g ionic@beta
ionic start helloionic2 blank --v2 --ts
cd helloionic2
ionic serve
Very interesting post.
LikeLiked by 1 person