mmmm
mmmm

Reputation: 3938

Removing cordova plugins from the project

Somehow in my app many of the cordova plugins are installed and because of that it requires access to almost everything - from my contacts to current location ( even though this app doesn't need this ).

This app is build via jenkins and as far as I understand one solution is to remove every plugin with single command, so it will be like:

cordova plugin rm org.apache.cordova.battery-status
cordova plugin rm org.apache.cordova.camera
cordova plugin rm org.apache.cordova.contacts
cordova plugin rm org.apache.cordova.geolocation
cordova plugin rm org.apache.cordova.media
cordova plugin rm org.apache.cordova.media-capture
cordova plugin rm org.apache.cordova.splashscreen
cordova plugin rm org.apache.cordova.vibration

But sometimes it shows some errors and with jenkins any error ends up with build failure, so is there any command which deletes all plugins? ( during installation basics plugins which requires any app to work are added automatically via cordova, so I was looking for some cordova plugin rm -all but couldn't find it )

Upvotes: 120

Views: 247482

Answers (15)

ruhanbidart
ruhanbidart

Reputation: 4824

First, you should list your plugins:

cordova plugin list

With this result, you can simply do:

cordova plugin remove <PLUGIN_NAME>

For example:

cordova plugin remove org.apache.cordova.media

Upvotes: 281

TheToster
TheToster

Reputation: 53

I am probably late, however there is a way...

Firstly, unfortunately there is no cordova plugin rm all, but we can work around it.

Just remove plugins dir and then re add all the plugins u need. But be ware this is not 'official' way to do it, but it works on both Android and iOS. I have just tested it, because I needed similar scripts for platform specific.

If u find it helpful consider pinning this response if possible.

Regards ;)

Upvotes: 0

Nathan Prather
Nathan Prather

Reputation: 2106

This is somewhat related and might help others, I had a corrupt version of some of my plugins so I was able to just delete the entire contents of the plugins folder. Note, all references are still in the package.json and config.xml files to the plugins. So then when I removed and added the Android platform, it re-installed the uncorrupted versions of the plugins and fixed my problem.

Upvotes: 0

user9972736
user9972736

Reputation: 131

cordova platform rm android

cordova plugin rm cordova-plugin-firebase

cordova platform add android

Upvotes: 4

rahul.sapkal23
rahul.sapkal23

Reputation: 727

If the above solution didn't work and you got any unhandled promise rejection then try to follow steps :

  1. Clean the Cordova project

    cordova clean

    1. Remove platform

cordova platform remove android/ios

  1. Then remove plugin

cordova plugin remove

  1. add platforms and run the project It worked for me.

Upvotes: 0

Mekkush
Mekkush

Reputation: 5

  • access the folder
  • list the plugins (cordova plugin list)
  • ionic cordova plugin remove "pluginName"

Should be fine!

Upvotes: 0

Olu Adeyemo
Olu Adeyemo

Reputation: 883

When running the command: cordova plugin remove <PLUGIN NAME>, ensure that you do not add the version number to the plugin name. Just plain plugin name, for example:

cordova plugin remove cordova.plugin_name 

and not:

cordova plugin remove cordova.plugin_name 0.01 

or

cordova plugin remove "cordova.plugin_name 0.01"

In case there is a privilege issue, run with sudo if you are on a *nix system, for example:

sudo cordova plugin remove cordova.plugin_name

Then you may add --save to remove it from the config.xml file. For example:

cordova plugin remove cordova.plugin_name --save

Upvotes: 0

DaveAlden
DaveAlden

Reputation: 30356

v2.0.0 of cordova-check-plugins enables you to remove all plugins in a project:

$ npm install -g cordova-check-plugins
$ cordova-check-plugins --remove-all

It will attempt to use the Cordova CLI to remove each plugin, but if this fails it will force removal of the plugin from platforms/ and plugins/.

If you also want to remove from config.xml, use:

$ cordova-check-plugins --remove-all --save

Disclaimer: I am the author of cordova-check-plugins

Upvotes: 10

Nacho Mar&#237;n
Nacho Mar&#237;n

Reputation: 71

Scripts based on processing the list of installed plugins may not work as there are dependencies between installed plugins (e,g, cordova-plugin-file and cordova-plugin-file-transfer).

In the example, the script will find the file plugin first, then it will try to remove it and we'll get an error as file-transfer requires it. Therefore, we shall have

Upvotes: 1

Hamid Tavakoli
Hamid Tavakoli

Reputation: 4647

You could use: cordova plugins list | awk '{print $1}' | xargs cordova plugins rm

and use cordova plugins list to verify if plugins are all removed.

Upvotes: 11

kuzyn
kuzyn

Reputation: 1995

From the terminal (osx) I usually use

cordova plugin -l | xargs cordova plugins rm

Pipe, pipe everything!

To expand a bit: this command will loop through the results of cordova plugin -l and feed it to cordova plugins rm.

xargs is one of those commands that you wonder why you didn't know about before. See this tut.

Upvotes: 14

JVE999
JVE999

Reputation: 3517

You can do it with bash as well (after switching to your Cordova project directory):

for i in `cordova plugin ls | grep '^[^ ]*' -o`; do cordova plugin rm $i; done

Upvotes: 21

Matthew Purdon
Matthew Purdon

Reputation: 773

I do it with this python one-liner:

python -c "import subprocess as sp;[sp.call('cordova plugin rm ' + p.split()[0], shell=True) for p in sp.check_output('cordova plugin', shell=True).split('\n') if p]"

Obviously it doesn't handle any sort of error conditions, but it gets the job done.

Upvotes: 4

Jack Shultz
Jack Shultz

Reputation: 2081

This is the commandline for removing plugins in Cordova

cordova plugin remove <pluginid>

For example I ran cordova plugin and got a list of plugins then I used the id for the plugin to uninstall

cordova plugin remove com.monday.contact-chooser

You can get help in the commandline by typing

cordova help <command>

Upvotes: 2

osayilgan
osayilgan

Reputation: 5893

As far as I remember from Cordova, you should have an xml file in "res" folder containing the list of plugins used in your project. You probably need to remove those unused plugins from list. And also you should remove related files.

Upvotes: 3

Related Questions