The Ionic command line interface (CLI) is your go-to tool for developing Ionic apps.
Use the ionic help
command for more detailed task information.
📣 Support/Questions?: Please see our Support Page for general support questions. The issues on GitHub should be reserved for bug reports and feature requests.
❤️ Want to contribute?: Please see CONTRIBUTING.md.
- Node 6+
- npm 3+
$ npm install -g ionic
📝 Note: For a global install of -g ionic
, OSX/Linux users may need to prefix
the command with sudo
or can setup proper file permissions on OSX for
npm to
install without sudo
.
We have rewritten the CLI from the ground up. Our main focus was to:
- Decrease the amount of time to the first start execution
- Improve the responsiveness of every CLI command
- Make the architecture flexible for future platform support (PWA, electron, etc.)
- Provide better help, more guidance, and more feedback when executing commands.
In doing so we decided to take a new approach to the CLI's structure. The base CLI installation now ships with global commands that are common to all Ionic apps.
Cordova commands have been namespaced and put into a CLI plugin, which is
installed by default with new Ionic projects and can be installed in existing
Ionic projects with npm i --save @ionic/cli-plugin-cordova
. For full details,
see below.
Here is a brief summary of changes in CLI 3. For more details and reasoning, see CHANGELOG.md.
- Removed commands:
setup
,share
,lib
,io
,security
,push
,config
,service
,add
,remove
,list
,hooks
,state
. - Added commands:
signup
. - Cordova commands have been namespaced (e.g.
ionic cordova build
, notionic build
). - Many command arguments, options, and flags have changed. Please use
ionic help <commands>
for command usage. generate
command has been overhauled to interactively generate components, pages, etc. Going forward, generators will continue to be improved.
$ ionic start --list
$ npm install -g ionic@latest
$ ionic start myNewProject
$ cd ./myNewProject
$ ionic serve
$ npm install -g ionic@latest
$ npm install --save-dev --save-exact @ionic/cli-plugin-ionic-angular@latest @ionic/cli-plugin-cordova@latest
$ ionic help
$ npm install -g ionic@latest
$ ionic start myNewProject blank --type ionic1
$ cd ./myNewProject
$ ionic serve
$ npm install -g ionic@latest
$ npm install --save-dev --save-exact @ionic/cli-plugin-ionic1@latest @ionic/cli-plugin-cordova@latest
$ ionic help
Integrate Ionic with Cordova to bring native capabilities to your app.
- For iOS development (macOS required), see the iOS Platform Guide.
- For Android development, see the Android Platform Guide.
$ npm install -g cordova
$ npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest
$ ionic cordova --help
$ ionic cordova run ios
The serve
command can add some proxies to the http server. These proxies are
useful if you are developing in the browser and you need to make calls to an
external API. With this feature you can proxy request to the external api
through the ionic http server preventing the No 'Access-Control-Allow-Origin' header is present on the requested resource
error.
In the ionic.config.json
file you can add a property with an array of proxies
you want to add. The proxies are object with the following properties:
path
: string that will be matched against the beginning of the incoming request URL.proxyUrl
: a string with the url of where the proxied request should go.proxyNoAgent
: (optional) true/false, if true opts out of connection pooling, see HttpAgent
{
"name": "appname",
"email": "",
"app_id": "",
"proxies": [
{
"path": "/v1",
"proxyUrl": "https://api.instagram.com/v1"
}
]
}
Using the above configuration, you can now make requests to your local server
at http://localhost:8100/v1
to have it proxy out requests to
https://api.instagram.com/v1
To proxy CLI requests, you will first need to install a CLI plugin:
$ npm install --save-dev --save-exact @ionic/cli-plugin-proxy
Then, set any of the following environment variables:
$ export http_proxy=http://internal.proxy.com
$ export HTTP_PROXY=http://internal.proxy.com
$ export PROXY=http://internal.proxy.com
$ export IONIC_HTTP_PROXY=http://internal.proxy.com
For example:
$ HTTP_PROXY=http://internal.proxy.com ionic login
To open Ionic documentation from the Ionic CLI, use ionic docs
.
The old version of the CLI can be installed with the legacy
tag:
npm install -g ionic@legacy