How to change bower's default cache folder?

≯℡__Kan透↙ 提交于 2019-12-21 03:39:18

问题


On *nix, bower uses the ~/.bower folder for its cache (packages and so on).
I would like to change this to a different location.

The bower spec document from suggests that I configure the storage key in my .bowerrc.

I have created one in my project folder like so:

{
  "storage": {
     "cache": "~/blah/cached",
     "git": "~/blah/git_templates"
  }
}

When running bower install - i see that it still tries to save into ~/.bower.

Can anyone tell me what I am doing wrong here ? And/or if there is a different way to change the location ?


回答1:


I had the same problem, after some tries according the spec, I gave up...

So I reviewed bower's history on github and found:

  • Before v0.10.0, bower used config.cache (lib/core/ResolveCache.js) for its cache location
  • After that, satazor rewrote bower's core, now using config.storage.cache at the beginning, i bet the spec doc was written at this time. From the spec:

storage [object]

Where to store persistent data, such as cache, needed by bower. Defaults to paths that > suite the OS/platform. Valid keys are cache, registry, links, completion.

  • However, after this commit, satazor now uses config.storage.packages instead of config.storage.cache

  • After that, in the v1.0.0 release, the config is always set to config.storage.packages, but the spec has not reflected this change ever since

Solution

  • Export the environment variable bower_storage__packages
  • Use a .bowerrc such as:

    {
      "storage":{
          "packages":"/path/to/cache"
      }
    }
    

P.S.: I think that linking the spec doc in Google Docs isn't a good idea, maybe github would be a more sensible choice (since we can issue pull requests).




回答2:


What version of bower are you using? Bower 1.0.0 no longer uses ~/.bower. It follows the XDG spec, http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

The "storage" property is only valid for 1.0.0.



来源:https://stackoverflow.com/questions/17881116/how-to-change-bowers-default-cache-folder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!