Cordova lesson 1: Installing the Cordova CLI


The Cordova command-line tool is distributed as an npm package.

To install the cordova command-line tool, follow these steps:

1. Download and install Node.js. On installation you should be able to invoke node and npm on your command line.
Read more: How to install NodeJS on Centos

2. (Optional) Download and install a git client, if you don’t already have one. Following installation, you should be able to invoke git on your command line. The CLI uses it to download assets when they are referenced using a url to a git repo.

3. Install the cordova module using npm utility of Node.js. The cordova module will automatically be downloaded by the npm utility.

on OS X and Linux:

$ sudo npm install -g cordova

On OS X and Linux, prefixing the npm command with sudo may be necessary to install this development utility in otherwise restricted directories such as /usr/local/share. If you are using the optional nvm/nave tool or have write access to the install directory, you may be able to omit the sudo prefix. There are more tips available on using npm without sudo, if you desire to do that.

on Windows:

C:\>npm install -g cordova

The -g flag above tells npm to install cordova globally. Otherwise it will be installed in the node_modules subdirectory of the current working directory.

Following installation, you should be able to run cordova on the command line with no arguments and it should print help text.

Result:

C:\>npm install -g cordova
...
  | |   | +-- create-ecdh@4.0.0
  | |   | +-- create-hash@1.1.3
  | |   | | +-- cipher-base@1.0.4
  | |   | | `-- ripemd160@2.0.1
  | |   | |   `-- hash-base@2.0.2
  | |   | +-- create-hmac@1.1.6
  | |   | +-- diffie-hellman@5.0.2
  | |   | | `-- miller-rabin@4.0.1
  | |   | +-- pbkdf2@3.0.14
  | |   | +-- public-encrypt@4.0.0
  | |   | +-- randombytes@2.0.5
  | |   | `-- randomfill@1.0.3
  | |   +-- defined@1.0.0
  | |   +-- deps-sort@2.0.0
  | |   +-- domain-browser@1.1.7
  | |   +-- duplexer2@0.1.4
  | |   +-- events@1.1.1
  | |   +-- glob@7.1.2
  | |   +-- has@1.0.1
  | |   | `-- function-bind@1.1.1
  | |   +-- htmlescape@1.1.1
  | |   +-- https-browserify@1.0.0
  | |   +-- insert-module-globals@7.0.1
  | |   | +-- is-buffer@1.1.6
  | |   | `-- lexical-scope@1.2.0
  | |   |   `-- astw@2.2.0
  | |   |     `-- acorn@4.0.13
  | |   +-- JSONStream@1.3.2
  | |   | `-- jsonparse@1.3.1
  | |   +-- labeled-stream-splicer@2.0.0
  | |   | `-- stream-splicer@2.0.0
  | |   +-- module-deps@4.1.1
  | |   | +-- detective@4.7.1
  | |   | `-- stream-combiner2@1.1.1
  | |   +-- os-browserify@0.1.2
  | |   +-- parents@1.0.1
  | |   | `-- path-platform@0.11.15
  | |   +-- path-browserify@0.0.0
  | |   +-- process@0.11.10
  | |   +-- querystring-es3@0.2.1
  | |   +-- read-only-stream@2.0.0
  | |   +-- readable-stream@2.3.3
  | |   | +-- core-util-is@1.0.2
  | |   | +-- isarray@1.0.0
  | |   | `-- process-nextick-args@1.0.7
  | |   +-- resolve@1.5.0
  | |   | `-- path-parse@1.0.5
  | |   +-- shasum@1.0.2
  | |   | +-- json-stable-stringify@0.0.1
  | |   | `-- sha.js@2.4.9
  | |   +-- shell-quote@1.6.1
  | |   | +-- array-filter@0.0.1
  | |   | +-- array-map@0.0.0
  | |   | +-- array-reduce@0.0.0
  | |   | `-- jsonify@0.0.0
  | |   +-- stream-browserify@2.0.1
  | |   +-- stream-http@2.7.2
  | |   | +-- builtin-status-codes@3.0.0
  | |   | `-- to-arraybuffer@1.0.1
  | |   +-- string_decoder@1.0.3
  | |   +-- subarg@1.0.0
  | |   | `-- minimist@1.2.0
  | |   +-- syntax-error@1.3.0
  | |   | `-- acorn@4.0.13
  | |   +-- through2@2.0.3
  | |   +-- timers-browserify@1.4.2
  | |   +-- tty-browserify@0.0.0
  | |   +-- url@0.11.0
  | |   | +-- punycode@1.3.2
  | |   | `-- querystring@0.2.0
  | |   +-- util@0.10.3
  | |   | `-- inherits@2.0.1
  | |   +-- vm-browserify@0.0.4
  | |   | `-- indexof@0.0.1
  | |   `-- xtend@4.0.1
  | +-- cordova-serve@2.0.0
  | | +-- compression@1.7.1
  | | | +-- accepts@1.3.4
  | | | | `-- negotiator@0.6.1
  | | | +-- bytes@3.0.0
  | | | +-- compressible@2.0.12
  | | | +-- debug@2.6.9
  | | | | `-- ms@2.0.0
  | | | +-- on-headers@1.0.1
  | | | +-- safe-buffer@5.1.1
  | | | `-- vary@1.1.2
  | | +-- express@4.16.2
  | | | +-- array-flatten@1.1.1
  | | | +-- body-parser@1.18.2
  | | | | +-- http-errors@1.6.2
  | | | | | `-- setprototypeof@1.0.3
  | | | | +-- iconv-lite@0.4.19
  | | | | `-- raw-body@2.3.2
  | | | +-- content-disposition@0.5.2
  | | | +-- content-type@1.0.4
  | | | +-- cookie@0.3.1
  | | | +-- cookie-signature@1.0.6
  | | | +-- depd@1.1.1
  | | | +-- encodeurl@1.0.1
  | | | +-- escape-html@1.0.3
  | | | +-- etag@1.8.1
  | | | +-- finalhandler@1.1.0
  | | | | `-- unpipe@1.0.0
  | | | +-- fresh@0.5.2
  | | | +-- merge-descriptors@1.0.1
  | | | +-- methods@1.1.2
  | | | +-- on-finished@2.3.0
  | | | | `-- ee-first@1.1.1
  | | | +-- parseurl@1.3.2
  | | | +-- path-to-regexp@0.1.7
  | | | +-- proxy-addr@2.0.2
  | | | | +-- forwarded@0.1.2
  | | | | `-- ipaddr.js@1.5.2
  | | | +-- qs@6.5.1
  | | | +-- range-parser@1.2.0
  | | | +-- send@0.16.1
  | | | | +-- destroy@1.0.4
  | | | | `-- mime@1.4.1
  | | | +-- serve-static@1.13.1
  | | | +-- setprototypeof@1.1.0
  | | | +-- statuses@1.3.1
  | | | +-- type-is@1.6.15
  | | | | `-- media-typer@0.3.0
  | | | `-- utils-merge@1.0.1
  | | `-- open@0.0.5
  | +-- dep-graph@1.1.0
  | | `-- underscore@1.2.1
  | +-- dependency-ls@1.1.1
  | | `-- q@1.4.1
  | +-- detect-indent@5.0.0
  | +-- glob@7.1.1
  | | `-- fs.realpath@1.0.0
  | +-- init-package-json@1.10.1
  | | +-- glob@7.1.2
  | | +-- npm-package-arg@5.1.2
  | | +-- promzard@0.3.0
  | | +-- read@1.0.7
  | | | `-- mute-stream@0.0.7
  | | +-- read-package-json@2.0.12
  | | | +-- glob@7.1.2
  | | | +-- json-parse-better-errors@1.0.1
  | | | +-- normalize-package-data@2.4.0
  | | | | `-- is-builtin-module@1.0.0
  | | | |   `-- builtin-modules@1.1.1
  | | | `-- slash@1.0.0
  | | +-- validate-npm-package-license@3.0.1
  | | | +-- spdx-correct@1.0.2
  | | | | `-- spdx-license-ids@1.2.2
  | | | `-- spdx-expression-parse@1.0.4
  | | `-- validate-npm-package-name@3.0.0
  | |   `-- builtins@1.0.3
  | +-- nopt@4.0.1
  | +-- opener@1.4.2
  | +-- plist@2.0.1
  | | +-- base64-js@1.1.2
  | | `-- xmlbuilder@8.2.2
  | +-- properties-parser@0.3.1
  | | `-- string.prototype.codepointat@0.2.0
  | +-- q@1.0.1
  | +-- request@2.79.0
  | | +-- aws-sign2@0.6.0
  | | +-- aws4@1.6.0
  | | +-- caseless@0.11.0
  | | +-- combined-stream@1.0.5
  | | | `-- delayed-stream@1.0.0
  | | +-- extend@3.0.1
  | | +-- forever-agent@0.6.1
  | | +-- form-data@2.1.4
  | | | `-- asynckit@0.4.0
  | | +-- har-validator@2.0.6
  | | | +-- commander@2.12.2
  | | | +-- is-my-json-valid@2.17.1
  | | | | +-- generate-function@2.0.0
  | | | | +-- generate-object-property@1.2.0
  | | | | | `-- is-property@1.0.2
  | | | | `-- jsonpointer@4.0.1
  | | | `-- pinkie-promise@2.0.1
  | | |   `-- pinkie@2.0.4
  | | +-- hawk@3.1.3
  | | | +-- boom@2.10.1
  | | | +-- cryptiles@2.0.5
  | | | +-- hoek@2.16.3
  | | | `-- sntp@1.0.9
  | | +-- http-signature@1.1.1
  | | | +-- assert-plus@0.2.0
  | | | +-- jsprim@1.4.1
  | | | | +-- assert-plus@1.0.0
  | | | | +-- extsprintf@1.3.0
  | | | | +-- json-schema@0.2.3
  | | | | `-- verror@1.10.0
  | | | |   `-- assert-plus@1.0.0
  | | | `-- sshpk@1.13.1
  | | |   +-- asn1@0.2.3
  | | |   +-- assert-plus@1.0.0
  | | |   +-- bcrypt-pbkdf@1.0.1
  | | |   +-- dashdash@1.14.1
  | | |   | `-- assert-plus@1.0.0
  | | |   +-- ecc-jsbn@0.1.1
  | | |   +-- getpass@0.1.7
  | | |   | `-- assert-plus@1.0.0
  | | |   +-- jsbn@0.1.1
  | | |   `-- tweetnacl@0.14.5
  | | +-- is-typedarray@1.0.0
  | | +-- isstream@0.1.2
  | | +-- json-stringify-safe@5.0.1
  | | +-- mime-types@2.1.17
  | | | `-- mime-db@1.30.0
  | | +-- oauth-sign@0.8.2
  | | +-- qs@6.3.2
  | | +-- stringstream@0.0.5
  | | +-- tunnel-agent@0.4.3
  | | `-- uuid@3.1.0
  | +-- shelljs@0.3.0
  | +-- tar@2.2.1
  | | +-- block-stream@0.0.9
  | | `-- fstream@1.0.11
  | |   `-- rimraf@2.6.2
  | |     `-- glob@7.1.2
  | +-- valid-identifier@0.0.1
  | `-- xcode@1.0.0
  |   +-- pegjs@0.10.0
  |   +-- simple-plist@0.2.1
  |   | +-- bplist-creator@0.0.7
  |   | | `-- stream-buffers@2.2.0
  |   | `-- plist@2.0.1
  |   |   +-- base64-js@1.1.2
  |   |   `-- xmlbuilder@8.2.2
  |   `-- uuid@3.0.1
  +-- editor@1.0.0
  +-- insight@0.8.4
  | +-- async@1.5.2
  | +-- chalk@1.1.3
  | | +-- ansi-styles@2.2.1
  | | +-- escape-string-regexp@1.0.5
  | | +-- has-ansi@2.0.0
  | | +-- strip-ansi@3.0.1
  | | `-- supports-color@2.0.0
  | +-- configstore@1.4.0
  | | `-- uuid@2.0.3
  | +-- inquirer@0.10.1
  | | +-- ansi-escapes@1.4.0
  | | +-- ansi-regex@2.1.1
  | | +-- cli-cursor@1.0.2
  | | | `-- restore-cursor@1.0.1
  | | |   +-- exit-hook@1.1.1
  | | |   `-- onetime@1.1.0
  | | +-- cli-width@1.1.1
  | | +-- figures@1.7.0
  | | +-- lodash@3.10.1
  | | +-- readline2@1.0.1
  | | | +-- code-point-at@1.1.0
  | | | +-- is-fullwidth-code-point@1.0.0
  | | | `-- mute-stream@0.0.5
  | | +-- run-async@0.1.0
  | | +-- rx-lite@3.1.2
  | | `-- through@2.3.8
  | +-- lodash.debounce@3.1.1
  | | `-- lodash._getnative@3.9.1
  | +-- os-name@1.0.3
  | | +-- osx-release@1.1.0
  | | | `-- minimist@1.2.0
  | | `-- win-release@1.1.1
  | +-- tough-cookie@2.3.3
  | | `-- punycode@1.4.1
  | `-- uuid@3.1.0
  +-- nopt@3.0.1
  | `-- abbrev@1.1.1
  `-- update-notifier@0.5.0
    +-- configstore@1.4.0
    +-- is-npm@1.0.0
    +-- latest-version@1.0.1
    | `-- package-json@1.2.0
    |   +-- got@3.3.1
    |   | +-- duplexify@3.5.1
    |   | | +-- end-of-stream@1.4.0
    |   | | `-- stream-shift@1.0.0
    |   | +-- infinity-agent@2.0.3
    |   | +-- is-redirect@1.0.0
    |   | +-- is-stream@1.1.0
    |   | +-- lowercase-keys@1.0.0
    |   | +-- nested-error-stacks@1.0.2
    |   | +-- object-assign@3.0.0
    |   | +-- prepend-http@1.0.4
    |   | +-- read-all-stream@3.1.0
    |   | `-- timed-out@2.0.0
    |   `-- registry-url@3.1.0
    |     `-- rc@1.2.2
    |       +-- deep-extend@0.4.2
    |       +-- ini@1.3.5
    |       +-- minimist@1.2.0
    |       `-- strip-json-comments@2.0.1
    +-- repeating@1.1.3
    | `-- is-finite@1.0.2
    |   `-- number-is-nan@1.0.1
    +-- semver-diff@2.1.0
    `-- string-length@1.0.1

Leave a Reply