Search code examples
cordovaosx-mavericks

PhoneGap/Cordova platform commands won't work


Whether trying to update or add (after removing, which DID work), I get errors about missing directories/files, but it is looking in places where it shouldn't (and unsurprisingly can't find what it is looking for). Doesn't seem to matter from what directory I issue the commands.

This happened after updating from v3.1.0 to v3.4.0, which went through without any complaints.

When I issued "cordova platform update ios" or "cordova platform update android", I got a complaint that a "platforms" directory was missing from the directory 2 levels up from where my project directory is.

Here's the error trace (from an OSX-Mavericks machine):

$ cordova platform update android
Error: ENOENT, no such file or directory '/Users/scott/Dropbox/platforms'
    at Object.fs.readdirSync (fs.js:654:18)
    at Object.module.exports.listPlatforms (/usr/local/lib/node_modules/cordova/src/util.js:106:19)
    at update (/usr/local/lib/node_modules/cordova/src/platform.js:104:48)
    at CLI.platform (/usr/local/lib/node_modules/cordova/src/platform.js:281:20)
    at new CLI (/usr/local/lib/node_modules/cordova/src/cli.js:158:26)
    at Object.<anonymous> (/usr/local/lib/node_modules/cordova/bin/cordova:41:16)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

Solution

  • In-place upgrades of multiple cordova versions at once is not really supported. You may have luck downgrading to cordova 3.2, updating your project, then cordova 3.3, etc.

    However, the easiest and safest way to upgrade with such big moves is by re-creating your project using cordova create with the --copy-from argument to create a clone of your previous app assets.

    If you really want to try one more shot of an in-place upgrade, I suggest you delete your .cordova directories in your workspace and home dir. Won't necessarily fix your issues, but thats a change we've made in recent releases to not use those configs as much.