This article references some of the common commands via CLI (command-line interface) in running a Cordova app.
Platforms
Platforms are the environment(s) that you want to run your app on. We will add the 'ios' and 'android' platform and ensure they get saved to config.xml and package.json files.
To add a platform use the following command:
cordova platform add {platform}
Therefore, to add ios and android run:
cordova platform add ios
cordova platform add android
To get a list of the platforms in use, use the command
cordova platform ls
This action will give a response that shows both platforms (with respective versions) in use and those available. Such as:
Installed platforms:
android 10.1.2
ios 6.2.0
Available platforms:
browser ^6.0.0
electron ^3.0.0
osx ^6.0.0
Plugins
You can tap in existing features using Cordova plugins. Plugins are typically hosted on npm and you can search for them on the plugin search page.
To show the current plugins, run the command
cordova plugin ls
Response will be something like:
cordova-plugin-advanced-http 3.3.1 "Advanced HTTP plugin"
cordova-plugin-device 2.1.0 "Device"
cordova-plugin-file 7.0.0 "File"
cordova-plugin-ionic-keyboard 2.2.0 "cordova-plugin-ionic-keyboard"
cordova-plugin-ionic-webview 5.0.0 "cordova-plugin-ionic-webview"
cordova-plugin-splashscreen 6.0.1 "Splashscreen"
cordova-plugin-statusbar 3.0.0 "StatusBar"
cordova-sqlite-storage 6.0.0 "Cordova SQLite storage plugin - cordova-sqlite-storage plugin version"
Updating Cordova
After installing the Cordova utility, to update it to the latest version – run the following command:
npm update -g cordova
Want to install a specific version:
npm install -g cordova@11.0.0
To see which version is currently running, use the command:
cordova -v
Whereas, to search for the latest released cordova version, run:
npm info cordova version