Skip to content

Installing Apache Cordova

LingQL edited this page Sep 29, 2016 · 1 revision

What is Cordova

Apache Cordova is a set of device APIs that allow a mobile app developer to access native device function such as the camera or accelerometer from JavaScript. Combined with a UI framework such as jQuery Mobile or Dojo Mobile or Sencha Touch, this allows a smartphone app to be developed with just HTML, CSS, and JavaScript.

Installing Cordova

When you install packages via NPM, you have the choice of either installing them locally to a current project, or globally, meaning they are available anywhere on the system.

In general dependencies should just be installed locally to the project to avoid polluting your system with unnecessary junk, but for things like Cordova we probably want to install it globally as the cordova command line tool is used for various system wide tasks (e.g. creating a new project).

To install the Cordova command line tools you should do:

$ npm install -g cordova

The -g flag there means install cordova globally. This step might fail depending on how you have configured Homebrew, as it will try to install the cordova executable into your /usr/local/bin folder. This might fail if you do not have write permissions to that folder. If this is the case use the sudo command to install it like this:

$ sudo npm install -g cordova

sudo used like this means "execute the following command with full super user permissions", and will prompt you to enter your password to re-authenticate you.

Verifying Cordova is installed properly

To verify your installation, open a new terminal window and run:

cordova --version

which should print out the installed version of Cordova to the command line. At time of writing I have version 4.3.0 installed.

Clone this wiki locally