我在我的项目中使用了几个开源的js库。我最近开始使用bower来处理所有前端依赖项。我喜欢我怎么能提供一个github网址而不是一个正确的包名。
我定制了几个库。因此,为了使用bower管理它们,我在Github上的组织帐户中创建了一个名为myLibs
的私有存储库。
我正在为每个自定义库创建分支。例如,自定义angular-bootstrap
库将位于angular-bootstrap
分支中,自定义angular-material
库将位于angular-material
分支中。
现在我正在为每个库中的每个版本创建标签。我使用的命名约定是branch-name/x.y.z
例如,我有angular-bootstrap/1.0.0
和angular-material/1.1.1
标记。
这很好,直到我不得不使用bower安装这些库。要安装自定义库,我调用了以下命令(它是一个虚拟URL,不要尝试)
bower install --save-exact library-patch=https://github.com/test_org/myLibs.git#branch-name/1.0.0
库已安装,我也可以在bower_components中看到它,但是在我的bower.json中,依赖项输入就像这样 -
"library-patch":"https://github.com/test_org/myLibs.git#undefined"
这不是我想要的。我想要保存正确的标签名称。每次我想添加自定义库时,我都不想在bower.json
文件中手动进行更改。
我的第一个想法是标签的命名约定将是一个问题。所以我在依赖项末尾从branch-name-x.y.z
#undefined`标签将其更改为branch-name/x.y.z which allowed me to have the exact version in the bower.json to install it properly, but when trying to install the libraries using the terminal, instead of using bower.json, I am getting the
。
这是从终端安装库时我得到的日志。
bower install --save-exact library-patch=https://github.com/test_org/myLibs.git#branch-name-1.0.0
bower not-cached https://github.com/test_org/myLibs.git#branch-name-1.0.0
bower resolve https://github.com/test_org/myLibs.git#branch-name-1.0.0
bower download https://github.com/test_org/myLibs/archive/branch-name-1.0.0.tar.gz
bower retry Download of https://github.com/test_org/myLibs/archive/branch-name-1.0.0.tar.gz failed with EHTTP, trying with git..
bower checkout library-patch#branch-name-1.0.0
bower resolved https://github.com/test_org/myLibs.git#branch-name-1.0.0
bower install library-patch#branch-name-1.0.0
library-patch#branch-name-1.0.0 bower_components/library-patch
└── angular#1.4.8
为什么我在发布/标记名称中未定义?在命名标签时我是否犯了错误?有什么办法可以从终端安装那些自定义库并在bower.json中保存确切的标签吗?
答案 0 :(得分:0)
问题的解决方案是使用--save
而不是--save-exact
。我现在没有相同的解释,但我会尽快更新答案。
据我所知,这是因为软件包直接从github安装,而不是从bower注册表安装。