Search code examples
androidcordovacross-platformphonegap-pluginscordova-3

How to Upgrade Cordova 3.5.0-0.2.4 to any higher version?


There are many questions in stackoverflow and in other blogs which says just execute the below command to upgrade-

sudo npm install -g cordova@5.1.1

After executing the above command in my terminal i get the following-

 /usr/bin/cordova -> /usr/lib/node_modules/cordova/bin/cordova
cordova@5.1.1 /usr/lib/node_modules/cordova
├── underscore@1.7.0
├── q@1.0.1
├── nopt@3.0.1 (abbrev@1.0.7)
└── cordova-lib@5.1.1 (valid-identifier@0.0.1, osenv@0.1.0, properties-parser@0.2.3, bplist-parser@0.0.6, mime@1.2.11, semver@2.1.0, unorm@1.3.3, shelljs@0.3.0, dep-graph@1.1.0, xcode@0.6.7, rc@0.5.2, cordova-app-hello-world@3.9.0, npm@1.3.4, elementtree@0.1.6, d8@0.4.4, npmconf@0.1.16, through2@0.6.3, glob@4.0.6, request@2.47.0, cordova-registry-mapper@1.1.8, plist@1.1.0, init-package-json@1.6.0, tar@1.0.2, cordova-js@4.0.0)

After that if i execute-

cordova -g -v

i get 3.5.0-0.2.4 as the version. Couldn't find any solution to upgrade from 3.5.0-0.2.4 to higher version , any help would be great. Thank you in advance.


Solution

  • My guess is that sudo is hosing you up here. Running sudo cordova -v should spit out that version you installed. I try to avoid using sudo to install npm modules.

    This answer here has a lot of solid solutions in it: npm throws error without sudo

    There are some other solutions not included in that thread as well. I tried to find this answer yesterday to link you to as well, but was unable too: NPM modules won't install globally without sudo.

    I also had this happen when I first installed node, and based on that answer this was the quickest solution: sudo chown -R $USER /usr/local. That being said there is a concern about playing with permissions like that.

    While I haven't tried this myself, apparently installing node from this repository also resolves the error. After removing node, run:

    curl -sL https://deb.nodesource.com/setup | sudo bash - 
    sudo apt-get install -y nodejs