How do you delete all your bowling packages?

It is sometimes useful to rebuild the entire site and force bower to reinstall new versions of all packages in bower.json.

However, there seems to be no way to do this:

Attempt # 1:

$ bower uninstall bower not-installed 0 

No, this only works on a one-by-one basis, although a clean bower install uses bower.json.

Attempt # 2:

 $ bower install -f -l 0 $ 

No, despite the '-f', it does nothing if the dependencies are met.

Attempt # 3:

 $ rm -r bower_components $ 

! Ah, victory! ... wait, what is it?

 rm: bower_components: No such file or directory 

Oh my gosh, there is .bowrc in this project that sets up a directory for installing things.

My real horrible solution:

Run a custom script that:

 - Parse .bowerrc if one exists - Load the directory if one is specified in the json block - If the directory currently exists... - ...recursively delete the directory. 

It works, I suppose, but it's pretty annoying, you need to configure it several times.

Did I miss something?

Is there a simple bower command to remove locally installed modules?

It seems like the really basic functionality that I would have expected to uninstall bower.

(Actually this is not a very javascript question, but I will gladly agree with something that hooks into the bower module somehow so that this happens in a simple node script)

Context

Edit: if you want “motivation” for such a task, then this is: we have a jenkins server that builds our projects and runs tests. However, periodically this happens for no apparent reason; this is almost always because jenkins uses the previous copy of the repository with just git-pull to upgrade to the latest version before creating and running the tests; as a result, the previous bower_components directory exists, and it is filled with cached copies of various components.

Here are some examples of things that are # @ $ @ # $ 'd and require bower to start up again as a push install:

1) Some idiot (> _> fitvids) deletes the previous marked version of the project.

2) Some of the projects left the conversation / moved the github page

3) Some projects (> _> jquery) have changed the way files are placed in a version that is not related to the main version.

I understand that the “right” solution to this problem is: fix jenkins, so it creates a new temporary directory for each assembly .... but this is not under my control.

So, as a build step, I need to automate the way to remove panel components and force them to reinstall; either as a grunting task (part of the assembly), or during the jenkins build process. However, remember from (3) above that our projects use .bowerrc, therefore it is not as simple as simply deleting the folder.

It would be great if I could remove all existing components of the bowler as a preliminary step to do this job.

So ... back to the question: can this be done with a gazebo?

+64
javascript bower
Apr 08 '14 at 4:10
source share
8 answers

Updated Answer

If you are trying to upgrade all your packages, use

 $ bower update 

Original answer

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

After deleting the ones you want to delete, do -

 $ bower prune 
  • begin with -

     "devDependencies": { "angular": "~1.2.15", "angular-ui-router": "~0.2.10", "moment": "~2.5.1" } 
  • remove angular links from file -

     "devDependencies": { "moment": "~2.5.1" } 
  • execute

     $ bower prune 
  • Keep your angular dependencies removed.

+146
Apr 08 '14 at 4:30
source share

What about

  • edit the bower.json file
  • 'rm -Rf bower_components / *'
  • bower installation

I tried to upgrade to polymer 0.2.4 from 0.2.3. I cannot find a quick way to remove a set of dependencies. So I just deleted these polymer * dir under bower_components. But for some reason I was talking, remembering that I had a 0.2.3 set event with a modified bower.json. "Rm -Rf bower_component / *" seems to do the tricks.

+10
May 14 '14 at 12:30
source share

Actually, I am doing something a little more complicated, but this works for me:

  • for package in $(ls your_bower_components_folder); do bower uninstall "$package"; done;
  • bower install
+6
May 13, '15 at 15:27
source share

Package Removal

To remove a package, you can use the delete command and then the name of the package you want to remove.

bower removal

You can delete multiple packages at once by specifying package names.

bower uninstall jquery modernizr sass-bootstrap

+5
Aug 20 '15 at 8:39
source share

Adapting the Jumar Polanco answer to use it in Powershell, you can programmatically remove bowler components as follows:

In the Powershell interface, navigate to the location where the bower.json and bower_components folders are located. This is usually the root folder of the application.

Then you can run:

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

Depending on the dependencies of the packages, additional attention to the process may be required, since some requests that require additional input (Y / n) to continue the process may occur (for example, dependency conflicts).

0
Aug 21 '15 at 20:44
source share

I don't know what build tools you use, but if it includes Grunt with grunt-bowercopy , you can use the clean option. It deletes the bower_components folder (or everything that you configured to use it) after copying the necessary files.

Ideally, I would prefer something that did not require me to re-download all the dependencies with each assembly, but only those where the new installation version found a newer version.

I am also looking for the best solution for this, so I will update if I find it.

0
Mar 11 '16 at 22:48
source share

I used nombom for this (as a bonus, it also installs your npm packages from scratch again):

https://www.npmjs.com/package/nombom

0
Mar 11 '16 at 23:20
source share

This is what ultimately works for me using the Windows command line:

 forfiles /p .\bower_components /c "cmd /c cd .. && bower uninstall @fname" 
0
Jun 08 '16 at 21:39
source share



All Articles