PhoneGap command-line interface and node.js library.

PhoneGap CLI

PhoneGap command-line interface and Node.js library.

$ npm install -g phonegap@latest
$ phonegap create my-app    # create a PhoneGap project
$ cd my-app                 # change to project directory
$ phonegap run ios          # build and install the app to iOS
Usage: phonegap [options] [commands]


  PhoneGap command-line tool.


  create <path>        create a phonegap project
  build <platform>     build the project for specific platform
  install <platform>   install the project on a specific platform
  run <platform>       build and install the projectfor specific platform
  serve                serve a phonegap project
  local [command]      development on local system
  remote [command]     development in cloud with phonegap/build
  platform [command]   update a platform version
  help [command]       output usage information
  version              output version number


  -d, --verbose        allow verbose output
  -v, --version        output version number
  -h, --help           output usage information


  keyword            | local environment | remote environment
  android            | ✔                 | ✔
  blackberry10       | ✔                 | ✖
  ios                | ✔                 | ✔
  wp8                | ✔                 | ✔


  $ phonegap help create
  $ phonegap help remote build
  $ phonegap create path/to/my-app
  $ phonegap remote build android
Usage: phonegap local [command]


  Executes the command on the local system.

  This requires that platform SDK is correctly installed.


  build <platform>     build a specific platform
  install <platform>   install a specific platform
  run <platform>       build and install a specific platform
  plugin <command>     add, remove, and list plugins


  $ phonegap local build android
  $ phonegap local run android
  $ phonegap local plugin list
Usage: phonegap remote [command]


  Executes the command remotely using the cloud-based PhoneGap/Build service.


  login                login to PhoneGap/Build
  logout               logout of PhoneGap/Build
  build <platform>     build a specific platform
  install <platform>   install a specific platform
  run <platform>       build and install a specific platform


  $ phonegap remote login
  $ phonegap remote build android
  $ phonegap remote run android
var phonegap = require('phonegap');

Templates allow you to create a new app from an existing app template. The nice part about templates is that they are simply a Cordova-compatible app. Any existing app can be a template.

You can list the available templates with:

$ phonegap template list

You can create a new project from a template with:

$ phonegap create my-app --template hello-world

Adding a new template is easy.

  1. Add your template to the package.json template section.

     // the key is your template name (e.g. hello-world)
     // the url is a HTTP URL to a .tar.gz.
       "templates": {
         "hello-world": {
           "description": "Default hello world app for PhoneGap.",
           "url": ""
  2. Send us a pull request!

The PhoneGap CLI installs successfully but you do not have a command phonegap.

Depending on how node and npm were installed, your globally installed npm modules may not be in your PATH.

At the bottom of your npm install -g phonegap@latest installation log, you will see the following:

/usr/local/share/npm/bin/phonegap -> /usr/local/share/npm/lib/node_modules/phonegap/bin/phonegap.js

(Your path may be slightly different)

Open ~/.profile or ~/.bashrc, depending on what exists on your system, and add following line:

export PATH=$PATH:/usr/local/share/npm/bin

Open a new terminal tab or type the following command:

$ source ~/.profile
$ source ~/.bashrc

The command phonegap should now be available to you.

You receive the following error message when building an Android project:

throw new Error('The provided path "' + project + '" is not an Android

The first time that you build for a platform, the framework is downloaded from Apache Cordova.

The framework is stored locally in your home directory, such as ~/.cordova/lib.

Sometimes the framework is corrupted during the download. It can exist for two know reasons:

  1. Your Android SDK environment is not properly configured.
  2. Unknown issue related to Apache's servers or the untar operation.

First, you must properly configure your Android environment by following the platform setup guide.

Next, you must delete the cached Cordova Android framework (x.x.x is your version):


Next, you can try to rebuild the project. Enabling verbose mode is sometimes helpful:

$ phonegap build android --verbose

There are a few steps that should be taken when upgrading to a new version of the cordova-cli.

  1. Update the package.json dependencies version for cordova.

       "dependencies": {
         "cordova": "3.1.0"
  2. Update the package.json version.

       "version": "3.1.0-0.15.0"
  3. Run the tests.

     $ npm test
  4. Commit stating the version increment.

     $ git commit -am "Version 3.1.0-0.15.0"
  5. Tag the version commit.

     $ git tag 3.1.0-0.15.0
  6. Update the PhoneGap Hello World App to match the new version.

  1. Manually test that the latest Hello World app is lazy-loaded.

     # Link the phonegap-cli for easier development (only need to do once).
     $ cd phonegap-cli/
     $ [sudo] npm link .
     # Manually test and verify hello world app is lazy-loaded.
     $ phonegap create my-app
     [phonegap] missing library phonegap/www/3.1.0
     [phonegap] downloading
     [phonegap] created project at /Users/mwbrooks/Development/sandbox/my-app
     $ cd my-app/
     $ phonegap run ios
  2. Push the git commit after the Hello World has been updated.

     $ git push phonegap master
  3. Publish the npm release.

     $ npm publish