0

I use cordova for app deveolopment and have some projects which were build with Cordova 3.5. The exact version is:

$ cordova --version
3.5.0-0.2.7

The cordova installation is global on my system, but now I think, that this was a bad idea. I really should have local, project specific installs, so older projects can be maintained with the original version and new projects can be started with the newest one.

The plan to fix this is as follows:

First remove the globally installed cordova:

$ sudo npm uninstall cordova -g

Then add specific cordova version to old projects

$ cd /Projects/old_project
$ sudo npm install cordova@3.5.0-0.2.7

$ cd /Projects/some_other_old_project
$ sudo npm install cordova@3.1

Finally add newest cordova for new project

$ cd new_project
$ sudo npm install cordova

The newest project will use the ionic framework, which was also installed using the -g switch. I'd like to replace this installation with a local, project specific install too.

Is this the correct way to do this? Or do I miss something? (and ruin everything?)

Gisela
  • 1,194
  • 2
  • 16
  • 30

1 Answers1

1

The way you describe is the correct way to do this, but you will need to keep in mind that you cannot use cordova run android anymore for example, but need to target the binaries in the npm_modules folder.

Also, you will need to save the versions of the cordova libraries with sudo npm install cordova --save-dev so your version numbers will be preserved in different environments.

Ricconnect
  • 1,089
  • 5
  • 25
  • Why is that the correct way? Normaly you have a cordova.js in every Project you create. That one is not updating, also not if you're updating your cordova version via sudo npm update -g cordova. You can work on every project as long as you want to on the version you build the project the first time. I don't know why you ever want to rebuild that project? – Sithys Mar 31 '15 at 09:26
  • 1
    But you will encouter situations that you need to remove for example an android project and re-add them for problems. You will also need to rebuild when someone else is working on the same project and you use source control (which I presumed). To prevent these situation your solution to locally define the cordova version is the best way. – Ricconnect Mar 31 '15 at 09:33
  • Okay, for that reasons it seems to be the best way. But we also work with 4 persons at projects with sourcecontrol and never had problems with building, removing platforms, adding plugins or things like that. – Sithys Mar 31 '15 at 09:40
  • You probably check in the whole projects then in source control? Otherwise you will need to build the project every time you check-out from source control. It is recommended to not check in ["artifacts"](http://stackoverflow.com/questions/16989933/what-parts-of-cordova-cli-generated-projects-can-be-safely-versioned-in-source-c) like android build code. – Ricconnect Mar 31 '15 at 09:46
  • Why do i have to build it again? We work for every platform on its own - so directly in the platforms -> "ios" folder for example. We define a codebasis and then doing the stuff for the platforms directly in the www folders for them. – Sithys Mar 31 '15 at 09:58
  • Then you do not work as Cordova is described to use, and you do not make use of tools like `cordova run android`. You suppose to make the implementation in the root www folder, and create your platform specific implementation in the root merges folder. – Ricconnect Mar 31 '15 at 10:22
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/74184/discussion-between-sithys-and-ricconnect). – Sithys Mar 31 '15 at 10:34
  • Thx for the answer. Especially for referencing the --save-dev flag. – Gisela Apr 01 '15 at 11:17