Updating and Reverting to Different Cordova PhoneGap Versions

If you want to update your version of Cordova PhoneGap to the latest version, or you want to revert to an earlier version (to test or debug), here are the steps to follow. I also have instructions on updating the plugins and platform versions here.


Cordova blog for latest updates:

Updating Cordova

First check what version you are running. Run Terminal and type the following. (You don’t have to be within a project folder to do any of the steps in this article.)

cordova -v

If my output was:


. . . I could update to the latest version of Cordova PhoneGap via CLI by typing:

npm update -g cordova

(Or replace cordova with phonegap, whichever one you started out with.)

If you get this output:

npm http GET https://registry.npmjs.org/cordova
npm http 304 https://registry.npmjs.org/cordova

. . . there was no update available.

If you get this error output:

Please try running this command again as root/Administrator.

 . . . try this in Terminal instead:

sudo npm install -g cordova

(Updating cordova also updates its tools: cordova-libs, plugman, and cordova-js.)

Is it possible to revert to an earlier version? Yes. We can learn what versions we can update to (or revert to) with:

npm info cordova

To revert from 3.5.0 to 3.4.0, I would first type in the terminal:

npm install -g cordova

. . . then highlight an earlier version in the list:


. . . and paste it at the end so it reads like the following, and hit Enter:

npm install -g cordova@3.4.1-0.1.0

Then verify the current install with:

cordova -v

A. At one point I got the error in the console:

404 Not Found: 5.0.0 
'5.0.0' is not in the npm registry.

My mistake was leaving out the “@” symbol in the command: cordova@3.4.1-0.1.0

B. Another time I got the error:

Error: EACCES, unlink '/usr/local/lib/node_modules/cordova/.npmignore'
Please try running this command again as root/Administrator.

So I ran the code with “sudo” in front like this, entered the unit’s Admin password, and it ran successfully:

sudo npm install -g cordova@5.0.0

Updating Plugins

If you encounter issues with an individual plugin, by all means let your debugging include removing the plugin and adding it again. To do that, follow these steps:

a. In terminal, type the following to see the plugins installed.

cordova plugin ls

I got:

cordova-plugin-inappbrowser 1.0.1 "InAppBrowser"
cordova-plugin-splashscreen 2.1.0 "Splashscreen"
cordova-plugin-whitelist 1.0.0 "Whitelist"

b. Highlight the plugin you want to remove, and copy it.

c. In terminal, type in the remove command and paste in the copied plugin:

cordova plugin rm cordova-plugin-inappbrowser

d. To install again, type in the add command in the terminal, and paste in the copied plugin

cordova plugin add cordova-plugin-inappbrowser

Note that Cordova does not have a way to update plugins. If you know of an updated plugin, then you simply following the a, b, c steps above to install the new plugin version.

You can batch update plugins with rm and add like so:

cordova plugin rm cordova-plugin-inappbrowser cordova-plugin-camera

You can check which plugins are available with a search. For instance, to search for a bar code plugin:

cordova plugin search bar code

You may want to take advantage of the newer, faster WKWebkit engine.

cordova plugin add cordova-plugin-wkwebview-engine --save

Regarding using Whitelist in iOS apps, read this: http://devgirl.org/2016/01/11/a-faster-hybrid-app-for-the-new-year/

Updating a Platform

To update a particular platform (perform this command one at a time for each platform), do the following command. However, this will remove the entire /android folder, so all your images in /platforms/android/res/drawable* will be lost. Make sure you have backups of these images first, or simply copy the /res folder to your root directory before updating, then copy them back.

To see what version of platform is installed, type:

cordova platform ?

I got:

Installed platforms: android 4.1.1, ios 3.9.2
Available platforms: amazon-fireos, blackberry10, browser, firefoxos, osx, webos

Note that the information will be returned based on which project you are in. “cd” to your project folder, then run the command.

When I received notice from Google Play of a security risk and was told to update the app to the latest version, it’s not enough to update Cordova. We need to update the Android platform for that project, as follows. 

To update the platform, remove the platform, then add it again:

cordova platform rm android
cordova platform add android@latest

Or simply use the update command:

cordova platform update android

Also see http://cordova.apache.org/announcements/2015/08/04/cordova-ios-3.9.0.html

cordova platform update ios@4.0.1


cordova platform add ios@4.0.1 --save

Cordova 4.0 and higher needs ios-deploy, so add it:

npm install -g ios-deploy

Updating Node and npm

You’ll need to update Node and npm occasionally, especially if you are getting console errors that don’t seem to make sense.

In the console, check the version:

node -v

Visit the Nodejs site to check it against the latest stable version: https://nodejs.org/en/ Install the latest version; it will be a pkg file. Double-click on it to start the install process. It might require password access to your computer (Mac), so stick around to enter it.  When the process is done, it will tell  you (Mac):

Node.js was installed at
npm was installed at
Make sure that /usr/local/bin is in your $PATH.

(This will also update npm.) Start a new console session and check the version as above.

If you get errors that are related to npm (such as Error: Cannot find module ‘semver’), then upgrade npm by itself:

sudo npm update -g

This will require that you enter your password.


6 thoughts on “Updating and Reverting to Different Cordova PhoneGap Versions

  1. Pingback: Signing an Android Apk Apart from Eclipse (in Mac OS X) | iPhone Dev Log

  2. It helped me a lot,I downgrade cordova from 5.0 to 3.5 and it is working fine.In 5.0 version I struggled with new terms gradle ,whitlist.

  3. Pingback: Using Cordova CLI on Mac OS X to build iOS apps | iPhone Dev Log

  4. Pingback: Using Cordova 5.0 CLI on Mac OS X to build Android apps | iPhone Dev Log

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s