| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
The Ionic command line interface (CLI) is your go-to tool for developing Ionic apps.
Use ionic --help for more detailed command 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.
📝 We try our best to make sure the Ionic CLI works on the latest versions of Node and npm, as well.
$ npm install -g ionic📝 Note: For a global install -g ionic, macOS/Linux users may need to prefix with sudo or can setup proper file permissions for npm.
📝 Note: Running ionic will first look to see if you're in an Ionic project. If you are, it runs the locally installed CLI, if installed.
New projects are started with the ionic start command. For full details and examples, see:
ionic start --helpHere is a table of project types and links to their respective starter templates:
| Project Type | Start Command | Starter Templates |
|---|---|---|
| Ionic Angular | ionic start myApp | blank, tabs, sidemenu, conference, tutorial, super |
| Ionic 1 | ionic start myApp --type=ionic1 | blank, tabs, sidemenu, maps |
After you start your project, you can cd into the directory and serve it in your browser:
cd ./myApp
ionic serveIntegrate Ionic with Cordova to bring native capabilities to your app.
$ npm install -g cordova
$ ionic cordova --help
$ ionic cordova run iosIonic Pro is a powerful suite of tools and services designed for the entire app lifecycle, all in one integrated experience. Ionic Pro is fully supported in the Ionic CLI. Just use --pro-id with ionic start or ionic link as documented in the Pro Docs to switch to the new experience.
You can switch between Ionic Cloud (legacy) and Ionic Pro with ionic config set -g backend legacy and ionic config set -g backend pro.
As of CLI 3.8, the @ionic/cli-plugin-cordova and @ionic/cli-plugin-gulp have been deprecated in favor of integrations. Integrations are automatically detected and enabled, but can be easily disabled.
Integrations hook into CLI events. For example, when the Cordova integration is enabled, ionic cordova prepare will run after ionic build runs. See CLI Hooks.
| integration | enabled when... | disabled with... |
|---|---|---|
| Cordova | ionic cordova commands are run | ionic config set integrations.cordova.enabled false |
| Gulp | gulp exists in devDependencies of your package.json | ionic config set integrations.gulp.enabled false |
The CLI will look for the following environment variables:
CLI flags are global options that alter the behavior of a CLI command.
The CLI provides commands for setting and printing config values from project config files and the global CLI config file. See ionic config set --help and ionic config get --help for usage.
CLI hooks are how you can run scripts during CLI events, such as "watch" and "build". To hook into the CLI, use the following npm scripts in your package.json file:
| npm script | description | commands |
|---|---|---|
| ionic:watch:before | Runs before the file watcher activates during a "watch" event | ionic serve, ionic cordova run -l, ionic cordova emulate -l |
| ionic:build:before | Runs before the Ionic "build" event starts. | ionic build, ionic upload, ionic package build, ionic cordova build, ionic cordova run, ionic cordova emulate |
| ionic:build:after | Runs after the Ionic "build" event finishes. | ionic build, ionic upload, ionic package build, ionic cordova build, ionic cordova run, ionic cordova emulate |
"scripts": {
"ionic:build:before": "cp somefile www/somefile",
}📝 Note: If you use gulp, the CLI will run gulp tasks by the same name as the npm scripts above.
The CLI can add proxies to the HTTP server for "livereload" commands like ionic serve, ionic cordova run android -lcs, or similar. 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 an object with the following properties:
{
"name": "appname",
"app_id": "",
"type": "ionic-angular",
"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.
📝 Note: Don't forget to change the URLs being requested in your app to the local URL. Also, the "livereload" command must be restarted for the proxy configuration to take effect.
To proxy HTTP requests performed by the CLI, you will need to install the CLI proxy plugin in the same node_modules context as the Ionic CLI:
For CLI installed globally:
$ npm install -g @ionic/cli-plugin-proxyFor CLI installed locally:
$ cd myProject # cd into your project
$ npm install --save-exact --save-dev @ionic/cli-plugin-proxyThen, use one of the following environment variables:
$ export HTTP_PROXY=http://proxy.example.org:8888 # used by npm
$ export HTTPS_PROXY=https://proxy.example.org:8888 # used by npm
$ export IONIC_HTTP_PROXY=http://proxy.example.org:8888You can configure the Ionic CLI's SSL (similar to configuring npm CLI):
$ ionic config set -g ssl.cafile /path/to/cafile # file path to your CA root certificate
$ ionic config set -g ssl.certfile /path/to/certfile # file path to a client certificate
$ ionic config set -g ssl.keyfile /path/to/keyfile # file path to a client key file📝 The cafile, certfile, and keyfile entries can be manually edited as arrays of strings in ~/.ionic/config.json to include multiple files.
| Back | FazBrowse Home | New Git URL |