Bower installation directory changes: sometimes the version is appended

我的未来我决定 提交于 2019-12-22 19:26:10

问题


I have a project that uses bower.

My bower.json:

{
  "name": "myproject",
  "version": "0.0.0",
  "dependencies": {
    ...
    "angular-sanitize": "1.2.1",
    ...

Then I run bower install.

Then I can see what's installed:

➜  myproject git:(develop) ✗ ls app/bower_components/angular-sanitize/
README.md                   angular-sanitize.min.js     bower.json
angular-sanitize.js         angular-sanitize.min.js.map

But then a coworker checkouts the project, he bower installs, on his machine, this dependency is installed in

app/bower_components/angular-sanitize/bower-angular-sanitize-v1.2.1/

instead of my original

app/bower_components/angular-sanitize/.


So why does bower sometimes adds bower-angular-sanitize-v1.2.1/ to the installation folder ?

Notes: We have the same bower.json and version of bower. If I delete my bower_dependencies and reinstall, I still have the old folder.


Edit:

What I understand (after playing a while with bower install a removing bower_components, clearing bower cache etc)...

My problem is linked to how bower resolves resolutions. It seems that versions are resolved once bower prompts you with a choice for choosing a few version (jquery, angular and bootstrap).

But still, a few things that I don't understand:

  • On my machine, even after removing bower cache, removing bower_dependencies or copying the bower.json in a new folder, bower never prompts me about resolutions after a "bower install" (so how are they stored?)

  • On my coworker machine, bower prompts for resolutions only on his native system (and not when "bower install"ing in a vagrant machine).

So, I have a few more obscure points: How does bower store the dependencies resolutions ? Is there documentation about this anywhere ? The only place I have found something is on some github issues (and by playing around with it).

My bower.json:

{
  "name": "myproject",
  "version": "0.0.0",
  "dependencies": {
    "json3": "~3.2.4",
    "bootstrap-sass": "~2.3.1",
    "es5-shim": "~2.0.8",
    "angular-cookies": "~1.2.1",
    "angular-dragdrop": "<=1.0.4",
    "angular-strap": "~0.7.1",
    "angulartics": "~0.8.4",
    "jquery": "~1.8.3",
    "underscore": "~1.4.4",
    "angular": "1.2.1",
    "angular-route": "1.2.1",
    "angular-resource": "1.2.1",
    "angular-sanitize": "1.2.1",
    "angular-ui-date": "~0.0.3",
    "jquery.masonry": "v2.1.08",
    "bootstrap": "~2.3.1",
    "angular-bootstrap": "~0.10.0",
    "highcharts": "~3.0.2",
    "jqueryui-timepicker-addon": "~1.4",
    "moment": "~2.0.0",
    "bootstrap-notify": "0.1.0",
    "mjaalnir-bootstrap-colorpicker": "~1.0.0"
  },
  "devDependencies": {
    "angular-mocks": "~1.0.7",
    "angular-scenario": "~1.0.7"
  },
  "resolutions": {
    "jquery": "~1.8.3",
    "angular": "1.2.1",
    "bootstrap": "~2.3.1"
  }
}

回答1:


We have the same problem here - it seems when the resolutions are defined within bower.json on install with empty cache and an empty bower_components directory, the package gets installed into bower_components/package/package-version whereas if you select the resolutions interactively during install, then it gets installed into bower_components/package - so if you hit that problem, clean the cache (e.g. bower cache clean), delete installed components (e.g. rm -rf bower_components/) and remove the resolutions from bower.json and then bower install.




回答2:


I had the same issue. I had to go trough every dependency and install it separately, check its version and then resolving it's resolution when asked. Once it worked and didn't put the folder with the package version number, then I saved the bower.json with the right version and with the resolution (again, when asked to). It worked for me, now all bower dependencies are versioned, no "*" or "latest", and some even without the "~" at the beginning of the version.

Hope this helps you and everyone facing this problem.



来源:https://stackoverflow.com/questions/21384890/bower-installation-directory-changes-sometimes-the-version-is-appended

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