Hackernoon logoIonic 2/3 CLI Reference by@amanhimself

Ionic 2/3 CLI Reference

Author profile picture

@amanhimselfAman Mittal

๐Ÿ‘จโ€๐Ÿ’ปDeveloper ๐Ÿ’œ Nodejs, React Native, Expo | Tech Writer at Draftbit| 2.5M+ views on Medium

The Ionic CLI is your go-to tool for developing Ionic apps.

Ionic CLI is a great tool when it comes to avoid writing a lot of boilerlpate code. It generates pages, services, can run or emulate your Ionic application with and generate needed resources for the mobile application such as splash screen.

This is a quick reference into Ionic CLI.

Installing the CLIย Tool

You can install it with npm:

To check if it has installed correctly, in your terminal window, type:

Starting a newย App

To start with a new mobile application, Ionic framework provides different set of ready-to-use templates:

For creating a new project:

With update to Ionic 3, no more adding tages such as --v2 after the template name in the above command. By default, Ionic app generated will be of version 2/3. To generate an Ionic app of version 1 (with good ol' Angularjs):

Serving

Once you cd into your projectโ€™s directory, serve your app on your local machine with serve:

To serve on a different port:

Use โ€“-lab tag to see your app side by side on multiple platforms (such as iOS, Android and Windows Mobile):

To serve without live reload:

Generating Providers andย Pages

To generate a new page:

To generate a provider/service:

Know them all- List the available generators:

Generating Resources

To generate the app icon and splash screen with resources:

Or, just the splash screen:

Now, generate resources for a specific platform:

Adding Platform

To add a target mobile platform for the app to use:

App on anย Emulator

To start an emulator:

Emulate with livereload:

Running Ionic App on a Connected Device

Letโ€™s say, I have an iOS device connected, so to run the app on that device:

Producion check:

Git Initialisation

Another advantage of using Ionic CLI tool is that it initialises a git repository when creating an Ionic project using the ionic start command from the terminal with an initial commit already. You can verify that by running:

You can also find me on Twitter

Author profile picture

@amanhimselfAman Mittal

Read my stories

๐Ÿ‘จโ€๐Ÿ’ปDeveloper ๐Ÿ’œ Nodejs, React Native, Expo | Tech Writer at Draftbit| 2.5M+ views on Medium

Tags

Join Hacker Noon

Create your free account to unlock your custom reading experience.