How to remove cordova-plugin-compat?

David Dal Busco picture David Dal Busco · Oct 3, 2017 · Viewed 10.8k times · Source

In the release notes of cordova-android 6.3.0 (https://cordova.apache.org/announcements/2017/09/27/android-release.html) it's written down that cordova-plugin-compat has to be removed

If I try

cordova plugin rm cordova-plugin-compat

I get following error

[ERROR] An error occurred while running cordova plugin remove cordova-plugin-compat --save (exit code 1):

Error: The plugin ‘cordova-plugin-compat’ is required by (cordova-plugin-calendar, cordova-plugin-camera, cordova-plugin-file, cordova-plugin-geolocation), skipping uninstallation. (try --force if trying to update)

If I then try to --force the remove, it works, the plugin is removed and I'm able to build my android app.

BUT, I just removed my iOS platform to add it again and I face now the error

cordova prepare ios Error: Cannot find plugin.xml for plugin "cordova-plugin-compat". Please try adding it again.

[ERROR] An error occurred while running cordova prepare ios (exit code 1).

Any idea what am I doing wrong? Should really cordova-plugin-compat be removed? Why my iOS platform is referencing it, I thought it was only for android?

I use [email protected] and [email protected]

P.S.: If I remove and add the iOS platform, the compat plugin is automatically added as reference in package.json and package-lock.json

UPDATE

The last plugin release (https://cordova.apache.org/news/2017/11/10/plugins-release.html) most probably solve this issue respectively it looks like that the problem was the reference to the cordova-plugin-compat plugin from other plugin. But,

I'm not yet able to totally test it and solve it because I'm using another plugin where compat is also referenced (https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin/issues/426).

I will keep this thread open till I could 100% confirm that this solve the referencing of compat.

FINAL UPDATE

The PR to remove the dependency from Calendar-PhoneGap-Plugin to ‘cordova-plugin-compat’ went thru, I was able to remove this last plugin without "force"

Answer

David Dal Busco picture David Dal Busco · Dec 8, 2017

The source of the problem was that plugins were directly referencing cordova-plugin-compat.

Therefore, even if the use of the plugin was deprecated, it was still needed. Forcing a deletion (using --force) wasn't a solution, because if I removed and added a platform again, then, because of these references, the plugin ‘cordova-plugin-compat’ was automatically added again during that process.

The solution of the problem was then to wait for new releases or to submit PR to remove the dependency.

In my case there were the plugins which were referencing cordova-plugin-compat:

Error: The plugin ‘cordova-plugin-compat’ is required by (cordova-plugin-calendar, cordova-plugin-camera, cordova-plugin-file, cordova-plugin-geolocation), skipping uninstallation. (try --force if trying to update)

Updating following plugins solved my issue:

[email protected], [email protected] and [email protected] removed the dependency (see https://cordova.apache.org/news/2017/11/10/plugins-release.html)

[email protected] removed the dependency thru this PR https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin/pull/430