Removing cordova plugins from the project

221,935

Solution 1

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

Solution 2

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

Solution 3

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.

Solution 4

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.

Solution 5

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

Share:
221,935

Related videos on Youtube

mmmm
Author by

mmmm

Updated on March 30, 2022

Comments

  • mmmm
    mmmm about 2 years

    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 )

    • QuickFix
      QuickFix over 10 years
      Y would recomment building a shell script that calls cordovaplugin list and then does cordova plugin rm for each line returned
    • mmmm
      mmmm over 10 years
      I can only do something like that through makefile. And also I'm not that good with unix command line.
    • QuickFix
      QuickFix over 10 years
      you can try to fill a request in the cordova project to ask them to add a command to remove all plugins...
    • mmmm
      mmmm over 10 years
      yeah, well I don't that much time to wait till they add a new command just for me..
  • mmmm
    mmmm over 10 years
    I don't have physical access to this slave. Can't be done this way.
  • Anthony Horne
    Anthony Horne over 8 years
    For some reason my VS2013 project does not list any and remove does not work. Gone to old fashion config.xml editing and plugin folder deletes...
  • Imon
    Imon over 8 years
    The guy asked for a command to delete all at a time. This is a simple documented answer to remove only one at a time.
  • kamayd
    kamayd over 7 years
    better to do cordova plugin remove <PLUGIN_NAME> --save so that it's automatically removed from config.xml
  • S.Yadav
    S.Yadav over 7 years
    cordova plugin remove com.monday.contact-chooser giving error as - Error: Plugin "cordova-plugin-name" is not present in the project. See cordova plugin list.
  • tim-montague
    tim-montague about 7 years
    Didn't work. Get the following error: Error: Plugin "{}" is not present in the project. See `cordova plugin list`
  • tim-montague
    tim-montague about 7 years
    This is a good point about dependencies between installed plugins. I think there's a force flag --force, which would remove the plugin regardless...
  • tim-montague
    tim-montague about 7 years
    Please remove your post, the question that was asked was "is there any command which deletes all plugins".
  • tim-montague
    tim-montague about 7 years
    Just use a shell script. Throwing yet another programming language with it's own dependencies into the mix makes Cordova an even bigger mess.
  • Hamid Tavakoli
    Hamid Tavakoli about 7 years
    @tfmontague try manually doing cordova plugins ls and then see if you can remove plugins one by one using cordova plugins rm plugin_name. From the error, it looks like one of the plugins are not physically present in your project. Using this method you can find that plugin.
  • Naga
    Naga about 6 years
    $cordova-check-plugins --remove-all --save Removing all plugins... -FATAL ERROR: Failed to find local/global cordova or global phonegap CLI command when listing installed plugins - ensure you have cordova npm module installed either locally in your project folder or globally. Error: Command failed: phonegap -v 'phonegap' is not recognized as an internal or external command, operable program or batch file.
  • NoodleOfDeath
    NoodleOfDeath about 6 years
    @Naga you need cordova or phonegap installed in your global npm directory which is specified by the default prefix npm config variable or whatever you set it to in your .npmrc/npmrc files. Most likely, yours is in C:\Users\yourusername\AppData\Roaming\npm if you are running on Windows or /usr/local on UNIX kernel. You can find out what your prefix is by typing in terminal/command npm config get prefix
  • Nur Amsyari
    Nur Amsyari about 5 years
    As of cordova 9.0.0 this no longer works correctly, JVE999's does work.
  • Joey Phillips
    Joey Phillips about 5 years
    Go ahead and add some context or explanation to your answer.
  • Hamid Araghi
    Hamid Araghi about 4 years
    Did you test it?
  • Inês Borges
    Inês Borges almost 2 years
    Not working as I expected but it is better than to write the name of all those plugins. I had to run the command as many times as there were plugins. One time for each plugin but it is always the same command so I just pressed the up arrow and clicked enter multiple times. Thanks for the fix ;)