How do you uninstall all your bower packages?

前端 未结 8 1510
礼貌的吻别
礼貌的吻别 2021-01-30 06:09

Sometimes it\'s useful to rebuild an entire site and force bower to reinstall new versions of all the packages in bower.json.

However, there doesn\'t seem to be any way

相关标签:
8条回答
  • 2021-01-30 06:45

    Adapting Jumar Polanco's answer to use it in Powershell, it is possible to programmatically uninstall bower components in the following way:

    In the Powershell interface, navigate to the location where bower.json and the bower_components folder is located. Usually is the root app folder.

    Then you can run:

    foreach($package in ls bower_components){bower uninstall $package}

    Depending on what the packages dependencies are, it may be required to pay extra attention to the process, as some prompts which require extra input (Y/n) to continue the process may arise (such as dependency conflicts).

    0 讨论(0)
  • 2021-01-30 06:53

    Updated Answer

    If you're trying to update all of your packages, use

    $ bower update
    

    Original Answer

    Go to your bower.json file and remove all of the components, or libraries, that you want to uninstall from devDependencies.

    After you have removed the ones you want gone, execute -

    $ bower prune
    
    1. start with -

      "devDependencies": {
          "angular": "~1.2.15",
          "angular-ui-router": "~0.2.10",
          "moment": "~2.5.1"
      }
      
    2. remove angular references from file -

      "devDependencies": {
          "moment": "~2.5.1"
      }
      
    3. execute

      $ bower prune
      
    4. watch your angular dependencies get uninstalled

    0 讨论(0)
  • 2021-01-30 06:55

    Actually I do something a little bit tricky but it works for me:

    1. for package in $(ls your_bower_components_folder); do bower uninstall "$package"; done;
    2. bower install
    0 讨论(0)
  • 2021-01-30 07:00

    I don't know what build tools you use, but if it includes Grunt with grunt-bowercopy, you could use the clean option. It removes the bower_components folder (or whatever you've configured it to use) after copying out the required files.

    Ideally, I'd prefer something that didn't require me to re-download all the dependencies with each build, but just the ones where doing a fresh install would find a newer version.

    I'm looking for a better solution to this as well, so I'll update if I find one.

    0 讨论(0)
  • 2021-01-30 07:05

    how about

    1. edit the bower.json
    2. 'rm -Rf bower_components/*'
    3. bower install

    I was trying to upgrade to polymer 0.2.4 from 0.2.3. I can't seem to find a quick way to uninstall a set of dependencies. So I just manually removed those polymer* dir under bower_components. But for some reason bower kept remembering I had 0.2.3 installed event with bower.json modified. A 'rm -Rf bower_component/*' seems to do the tricks.

    0 讨论(0)
  • 2021-01-30 07:05

    Uninstalling Packages

    To remove a package you can use the uninstall command followed by the name of the package you wish to remove.

    bower uninstall

    It’s possible to remove multiple packages at once by listing the package names.

    bower uninstall jquery modernizr sass-bootstrap

    0 讨论(0)
提交回复
热议问题