how to build multiple cordova applications with different cordova version

instead of installing the cordova client with

 npm install -g cordova   # DON'T USE THIS

You should just install the cordova client locally, the best way is to put the cordova dependency in the file package.json so when you run the npm install in the root folder of your application, it will install the appropriate cordova version related to this application.

 # if you have a well configured package.json
 npm install


 # without a package json
 # if you want the cordova version 5.2.0
 npm install cordova@5.2.0

But it is not enough because your path is not up to date so when you run cordova, it is still pointing to the global one. The trick is to run the following command (or add it to your .bashrc) :

 export PATH=./node_modules/cordova/bin:$PATH

then type again

 cordova -version

That’s it ! You are running cordova with local cordova client defined by the developer of the app.

Auteur/autrice : Chrystophe Vergnaud

Prendre du recul pour identifier les réels besoins et faire un choix technologique en fonction de ces besoins.

Laisser un commentaire