Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't update any plugins, not a valid cordova platform?

I have an issue when trying to update any plugin in cordova using mac os terminal. When I try to run the command cordova plugin add xxxxxxx it is telling me that both my android/ios are not valid cordova platforms.

My Node version is v9.2.0, NPM version is 5.5.1 and Cordova version is 7.1.0. I'm at a loss on how to proceed. Can anyone give some insight?

 ➜  steve git:(master) ✗ cordova plugin add https://github.com/danwilson/google-analytics-plugin.git
 Installing "cordova-plugin-google-analytics" for ios
 Unable to load PlatformApi from platform. Error: Cannot find module '/Users/rsteve/Desktop/steve/platforms/ios/cordova/Api.js'
Failed to install 'cordova-plugin-google-analytics': Error [ERR_UNHANDLED_ERROR]: Unhandled error. (The platform "ios" does not appear to be a valid cordova platform. It is missing API.js. ios not supported.)
at EventEmitter.emit (events.js:140:19)
at EventEmitter.module.exports.emit (/usr/local/lib/node_modules/cordova/node_modules/cordova-common/src/events.js:71:17)
at Object.getPlatformApiFunction (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/util.js:500:20)
at Object.getPlatformApi (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/platforms/platforms.js:55:25)
at handleInstall (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:593:29)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:357:28
at _fulfilled (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:787:54)
at self.promiseDispatch.done (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:816:30)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:749:13)
at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:509:49

Error: Unhandled error. (The platform "ios" does not appear to be a valid cordova platform. It is missing API.js. ios not supported.)

enter image description here

like image 559
chronotrigga Avatar asked Nov 28 '17 16:11

chronotrigga


People also ask

How do I update Cordova to latest version?

Update Cordova CLI, cordova Then compare the returned version number to the output of npm info cordova version (You can also check manually for the newest available version on npm or GitHub). Run cordova -v again after the update to make sure the update worked and it now returns the current version.

What are the different platforms supported by Cordova?

Cordova-Android requires the Android SDK, which can be installed on either macOS, Linux, or Windows.

Which command is used to install plugin in Cordova?

The cordova plugin add command requires you to specify the repository for the plugin code. Please note that when you follow the Web Project Dev workflow and use the CLI, the CLI will take care of adding the plugin code to the appropriate place for each platform.


1 Answers

In my experience, the following resolves almost all cordova plugin/platform issues:

cordova plugins --save
cordova platforms --save
rm -rf platforms
rm -rf plugins
cordova prepare

It does this by:

  1. saving plugin config
  2. saving platform config
  3. removing platforms folder
  4. removing plugins folder
  5. re-installing all platforms and plugins
like image 144
John Doherty Avatar answered Nov 15 '22 05:11

John Doherty