This chapter serves as a reference manual. You don’t need to learn everything at once; simply refer to it as needed.
CLI Syntax
cordova <command> [options] -- [platform-specific arguments]Code language: CSS (css)
Global Command List
Can be executed without navigating into a Cordova project directory
| Command | Description |
|---|---|
| create | Create a new project |
| help | Show documentation for a specified command |
| config | Set, query, delete, edit and list global Cordova configuration entries |
Project Command List
Must run inside the root directory of a valid Cordova project
| Command | Description |
|---|---|
| info | Print project environment details |
| requirements | Detect and output all required dependencies for target platforms |
| platform | Manage project platforms (Android/iOS/Browser, etc.) |
| plugin | Manage project plugins |
| prepare | Copy asset files to platform directories to get ready for compilation |
| compile | Compile the project for specified platforms |
| build | Build application (equivalent to prepare + compile) |
| clean | Clear cached build artifacts generated by platform compilation |
| run | Launch application (internally runs prepare + compile + deployment) |
| serve | Start local web server for web asset preview (triggers prepare internally) |
Common Options (Supported by all CLI commands)
| Argument | Description |
|---|---|
| -d / –verbose | Output detailed logs. If invoking cordova-cli within Node code, listen for log and warn events to capture logs: cordova.on('log', ()=>{}) |
| -v / –version | Print current Cordova CLI version |
| –nohooks | Prevent hook script execution; supports regular expression filtering for hooks |
Platform-Specific Arguments Explained
Certain commands support custom platform arguments (platformOpts).
Use -- as separator: parameters before -- are parsed by Cordova CLI, and all arguments after -- are passed directly to the native platform build tools.
CLI Usage Examples
Demonstration of complete workflow:
- Create project
- Install camera plugin
- Add Android platform
- Compile and run on Android
- Generate release build with Android signing parameters
# Create project
cordova create myApp com.foxdevelop.myApp myApp
cd myApp
# Add camera plugin
cordova plugin add cordova-plugin-camera
# Add Android platform
cordova platform add android
# Check Android build environment dependencies
cordova requirements android
# Compile Android with verbose logs
cordova build android --verbose
# Launch app on device/emulator
cordova run android
# Release build with signing arguments
cordova build android --release -- --keystore="..\android.keystore" --storePassword=android --alias=mykeyCode language: PHP (php)
Detailed Command Reference
cordova create
Generate directory structure for Cordova project.
Syntax:
cordova create path [packageId [appName]] [options]Code language: CSS (css)
Parameters
| Value | Description |
|---|---|
| path | Project folder (folder must not exist beforehand; CLI creates it automatically) |
| id | Package identifier, default: org.apache.cordova.hellocordovaReverse domain format, matches widget id inside config.xml; used to generate Java package names, configure appropriately |
| name | Application display name, default: Hello CordovaMaps to name field in config.xml and becomes native project class name |
Options
--template: Create project using custom template from local path, NPM or GitHub
cordova create myapp com.mycompany.myteam.myapp MyAppCode language: CSS (css)
cordova platform
Manage platforms: add, remove, update and list platforms. Adding or removing platforms modifies the project platforms directory.
cordova {platform | platforms} [
add <platform-spec> [...] {--save | link=<path> } |
{remove | rm} platform [...] {--save}|
{list | ls} |
update ]Code language: HTML, XML (xml)
Subcommands & Parameters
| Subcommand | Parameter | Description |
|---|---|---|
| add <platform-spec> | Add platform | |
| –nosave | Do not write platform information into config.xml / package.json after installation | |
| –link= | Create symbolic link instead of copying files when using local platform source (for platform development debugging) | |
| remove <platform> | Delete platform | |
| –nosave | Remove platform without erasing records inside config.xml / package.json | |
| update <platform> | Upgrade platform version | |
| –save | Update recorded platform version inside config.xml | |
| list / ls | List all installed and available platforms |
Platform Spec Format <platform-spec>
platform[@version] | local path | Git url[#branch/tag/commit]Code language: PHP (php)
- platform: platform name android / ios / browser / electron
- version: Semantic version semver, example
^13.0.0 - path: Local platform source directory / tar archive
- url: Git repository address
- commit-ish: Specify branch, tag, commit hash; defaults to master if omitted
Supported Platforms
android, browser, electron, ios
# Add Android and iOS and save records to config
cordova platform add android ios
# Add Android platform with specified version
cordova platform add android@^13.0.0
# Install platform from Git repository with specific tag
cordova platform add https://github.com/myfork/cordova-android.git#13.0.0
# Install platform from local folder
cordova platform add ../android
# Remove Android platform
cordova platform rm android
# View all platforms
cordova platform lsCode language: PHP (php)
cordova plugin
Manage project plugins
cordova {plugin | plugins} [
add <plugin-spec> [..] {--searchpath=<dir> | --noregistry | --link | --save | --force} |
{remove | rm} {<pluginId> | <name>} --save |
{list | ls}
]Code language: HTML, XML (xml)
Subcommand Parameters
| Subcommand | Parameter | Description |
|---|---|---|
| add <plugin-spec> | Add plugin | |
| –searchpath <dir> | Search local directories first for plugins; path separator Windows ;, Linux/Mac : | |
| –noregistry | Avoid fetching plugins from official npm registry | |
| –link | Create symbolic link when installing local plugin folder (for plugin debugging) | |
| –nosave | Skip writing records into config.xml / package.json | |
| –force | Force overwrite conflicting files (added in version 6.1) | |
| remove | Remove plugin | |
| –nosave | Delete plugin but keep records in configuration files | |
| list / ls | List installed plugins |
Plugin Spec Format <plugin-spec>
[@scope/]pluginId[@version] | local directory | Git url[#commit][:subfolder]Code language: PHP (php)
Plugin Resolution Priority (Highest → Lowest)
- Explicit plugin and version specified via command line
- Plugin information stored in config.xml / package.json
- Latest npm version compatible with current project (plugin package.json declares cordova dependency)
- Latest available plugin version on npm
# Install camera and file plugin, search ../plugins first
cordova plugin add cordova-plugin-camera cordova-plugin-file --searchpath ../plugins
# Install specific plugin version
cordova plugin add cordova-plugin-camera@^2.0.0
# Install plugin from local folder
cordova plugin add ../cordova-plugin-camera
# Remove plugin
cordova plugin rm cordova-plugin-camera
# List plugins
cordova plugin lsCode language: PHP (php)
Plugin Conflict Notes
Some plugins modify native configuration files via edit-config inside plugin.xml.
Conflicts occur when multiple plugins edit the same XML node; CLI blocks installation by default.
Solutions:
- Modify plugin plugin.xml to avoid editing identical nodes (Recommended)
- Force installation using
--force(⚠️ Risk: Overwrites modifications from other plugins and may break them)
cordova prepare
Synchronize config.xml settings to native manifest files for each platform; copy icons, splash screens and plugin assets; prepare project to satisfy native SDK build requirements.
cordova prepare [platformNames...]Code language: CSS (css)
All platforms are processed if no platform specified.
cordova compile
Run compilation only, prepare will not execute. Usually use build directly; mainly used for hook extension scenarios.
cordova compile [platforms...]
[--debug | --release]
[--device | --emulator | --target=<name>]
[--buildConfig=<file>]
[-- platform arguments]Code language: CSS (css)
cordova build
Equivalent to prepare + compile, builds application packages.
cordova build [platforms...]
[--debug | --release]
[--device | --emulator]
[--buildConfig=<configFile>]
[-- platform arguments]Code language: CSS (css)
| Parameter | Description |
|---|---|
| –debug | Debug build package |
| –release | Release production package |
| –device | Build package targeting physical devices |
| –emulator | Build package for emulator architecture |
| –buildConfig | Specify build configuration file, defaults to build.json in project root, commonly used for signing setup |
cordova build android --release --buildConfig=build.json
cordova build android --release -- --keystore="app.keystore" --alias=key0Code language: JavaScript (javascript)
cordova run
Execute prepare → build → deploy application to device/emulator and launch it.
cordova run [platforms...]
[--list | --debug | --release]
[--noprepare]
[--nobuild]
[--device | --emulator | --target=<name>]
[--buildConfig=<file>]
[-- platform arguments]Code language: CSS (css)
| Parameter | Description |
|---|---|
| –list | List all connected physical devices and emulators |
| –noprepare | Skip prepare step (6.2+) |
| –nobuild | Skip compilation, deploy existing built package directly |
| –target | Select specific emulator/device name, query names using --list |
Examples:
# List available devices
cordova run android --list
# Run on specified emulator
cordova run android --target=Nexus_5_API_23_x86
# Run without rebuilding
cordova run android --nobuildCode language: PHP (php)
cordova emulate
Alias for cordova run --emulator, launches app only inside emulator.
cordova clean
Remove compiled build artifacts for each platform
cordova clean android
cordova requirements
Check all environment dependencies required by platforms (JDK, Android SDK, Xcode, etc.)
cordova requirements android
Returns exit code 0 when all dependencies satisfied, non-zero value if missing dependencies. Widely used for automated build environment validation.
cordova info
Output full environment, platform and plugin information; required when submitting bug reports.
cordova info
cordova serve
Start local web server to preview www web assets, default port 8000
cordova serve 8080
# Access URL: http://127.0.0.1:8080/android/wwwCode language: PHP (php)
cordova help
View command documentation
cordova help build
cordova build -h
cordova config
Manage global Cordova configurations
cordova config ls # List all configurations
cordova config set save-exact true
cordova config get save-exact
cordova config delete save-exact
cordova config editCode language: PHP (php)
Cordova Command-Line Interface (CLI) Reference Manual