Install Ionic on Ubuntu 14.04

As Ionic depends on cordova, you need to install it first. To install Cordova, make sure you have Node.js installed. Following step by step guide shows what to do to install ionic so that you can build your brand new ionic app right away. This guide is intentionally made precise rather explaining much stuffs. Lets get going!

Install node.js (v4)

If you don’t have cURL installed, install it first:

sudo apt-get install php5-curl

Now run following commands:

curl -sL | sudo -E bash –
sudo apt-get install -y nodejs

To compile and install native addons from npm you may also need to install build tools: (optional)

sudo apt-get install -y build-essential

Install cordova:

After successful nodejs installation, now you need to install cordova to access cordova library when you need them.

sudo npm install -g cordova

If you are running a 64-bit version of Ubuntu, you’ll need to install the 32-bit libraries since Android is only 32-bit at the moment.

sudo apt-get install ia32-libs

If you are on Ubuntu 13.04 or greater, ia32-libs has been removed. You can use the following packages instead:

sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0

Install Ionic:

Ionic comes with a convenient command line utility to start, build, and package Ionic apps. To install it, simply run:

sudo npm install -g ionic

If you’ve come this far, you’ve successfully installed Ionic on your system. Now lets create a brand new app!

Create the project:

Now, its the time to create a new Cordova project:

ionic start todo blank

If you get Error: Cannot find module ‘xmlbuilder’, follow this step:

Remove nodejs
Delete the /usr/lib/node_modules (/usr/local/lib/node_modules) folder
Reinstall nodejs
Clear the npm cache (npm cache clean)
* Reinstalling ionic

Run app with a browser:

Go to your project root and run:

ionic serve

This will run demo app on your browser. While app is running, you can use following commands to do specific tasks needed:

  • restart or r to restart the client app from the root
  • goto or g and a url to have the app navigate to the given url
  • consolelogs or c to enable/disable console log output
  • serverlogs or s to enable/disable server log output
  • quit or q to shutdown the server and exit

If you are ok with web view of your app, then you’re done. Above steps are all you needed. But if you want to test your app on emulator/real device, keep moving…

Install Android Studio to work for android:

Make sure you’ve Oracle JDK 8 installed in your system ( ). Download and install android SDK from official site:

While installing (downloading), if you get this error:

Unable to run mksdcard SDK tool. One common reason for this is missing 32 bit compatibility libraries. Please fix the underlying issue and retry, run this command and retry downloading:

sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1

Now set ANDROID_HOME and point it to Sdk folder. Then update PATH variable so that you can user android command from terminal. Follow either steps below:

[Temporary] Open terminal and run these commands:

export ANDROID_HOME=”$HOME/Android/Sdk”
export PATH=”$PATH:$ANDROID_HOME/tools”
export PATH=”$PATH:$ANDROID_HOME/platform-tools”

[Permanent] Open terminal and run this:

gedit ~./profile

Add these lines to the bottom and save:

export ANDROID_HOME=”$HOME/Android/Sdk”
export PATH=”$PATH:$ANDROID_HOME/tools”
export PATH=”$PATH:$ANDROID_HOME/platform-tools”

Logout and login again. This will make android command available from terminal. If you don’t have .profile in home, run this and configure according to instruction. .profile will be created:

sudo passwd root

Run the app with an emulator:

Now, you need to tell ionic that you want to enable the iOS and Android platforms. Note: unless you are on MacOS, leave out the iOS platform:

ionic platform add android
ionic platform add ios

You’ll get this warning upon trying to add ios platform from linux machine: WARNING: Applications for platform ios can not be built on this OS - linux. To make local android build on application, run this command:

ionic build android

After successful build, you can now emulate your app. If you’ve properly configured AVD, you’ll see your app running on emulator in a while. For that, run following command:

ionic emulate android

If you get Error sh: 1 glxinfo not found in any stage of emulation, run following command to fix this:

sudo apt-get install mesa-utils

After BUILD is successfull, you’ll be able to emulate your app on emulator. To run your awesome app on real android device, just set debug mode ‘on’ from developer option, connect it to your pc and run following command:

ionic run android

Ta Da! Your app is running on your phone !!! Congratulations :smile:

Learn it all to be an Ionic Superhero:

[1] Ionic in your living room:
[2] Playground for ionic:
[3] Step by step Ionic:
[4] 8 reasons why I’m glad I switched to the ionic framework:
[5] 240+ Ionic Framework resources:
[6] Tutorialspoint:
[7] A comprehensive list of ionic starter apps:

[Source] CodeBlog: