If you are a Cordova* dev, you are familiar with the following command
npm install -g cordova
This command installs Cordova for you globally on the command line. But what if you want to install it in another location? You have to configure your path settings to search for it correctly. What if you want to use multiple versions (gasp)? There are a few blog posts out there detailing how to install multiple versions and alias them.
To the rescue
Inspired by tools like RVM* and NVM*, I created Version Manager for Cordova Software (cvm) to solve this problem. As part of the HTML5 tools team at Intel, I write and maintain a few Cordova plugins. Having to test them on different versions became cumbersome, especially with the Android* switch from Ant* to Gradle*. Based off my experience, the tools is designed to help plugin authors speed up the development and debugging cycle.
The tool
There are two parts to this CLI tool; Cordova version management and dispatching to the correct version of Cordova. The CLI tool allows you to install any valid version of Cordova, switch your current version, and uninstall versions of Cordova. The tool will create a .cvm directory in your home folder where it stores all the Cordova versions. It also creates a .cvmrc file that has the selected version of Cordova. You can always fall back to your system install instead of using a version supplied by cvm.
The second part intercepts calls to the "cordova" command and dispatches it to the correct version. We accomplish this by adding a new cordova file inside the .cvm folder and update our path environment variables to include the .cvm folder before our node modules.
Usage
The tool requires Node.js* and NPM* to be used. To install, simply run the command
npm install -g version-manager-cordova-software
After you install, you will need to configure your environment variables for the new cordova script. Windows* users who are using the command prompt, you need to modify the system PATH environment variable. Make sure it is before the entry to node_modules
c:\users\myaccount\.cvm;c:\users\myaccount\AppData\roaming\npm
If you are using a shell, such as cygwin* or gitbash*, use the following instructions. Update your shell profile, e.g .bash_profile, to export the path environment variable. After updating, you can restart your terminal or resource your shell profile.
export PATH="$HOME/.cvm:$PATH"
You now will have a new command cvm to manage your Cordova versions. Below are example commands to install, switch, and remove versions of Cordova
cvm install 5.1.1 - install version 5.1.1 cvm install 5.3.3 - install version 5.3.3 cvm use 5.3.3 - use version 5.3.3 cvm uninstall 5.1.1 - uninstall 5.1.1 cvm use system - use the system version of Cordova