我已经为我的应用程序安装了一些 Git 存储库,我通过执行以下操作来做到这一点:
bower install git://github.com/user/cooltool.git --save
grunt bower-install
然后我得到以下错误:
cooltool was not injected in your file.
Please go take a look in "app/bower_components/cooltool" for the file you need, then manually include it in your file.
直接从 GitHub 存储库安装的 Bower 组件是否总是需要手动添加到我的 index.html
文件中?如果没有,如何让它正确包含脚本?
Grunt 任务都是 yo angular-fullstack
脚手架工具的一部分。
gruntfile 的 bower-install
任务如下:
// Automatically inject Bower components into the app
'bower-install': {
app: {
html: '<%= yeoman.app %>/views/index.html',
ignorePath: '<%= yeoman.app %>/',
exclude: ['bootstrap-sass']
}
},
最终,我希望将cooltool bower 组件的脚本标记注入(inject)到我的 index.html
中的 Bower build:js 部分:
<!-- build:js(app) scripts/vendor.js -->
<!-- bower:js -->
<script ...>
<!-- endbower -->
<!-- endbuild -->
执行运行 bower install git://github.com/user/cooltool.git --save
后,为它创建了一个 Bower 目录,该目录内部是一个(隐藏) .bower.json
文件,但不是主 bower.json
文件:
.bower.json
:
{
"name": "d3-cloud",
"homepage": "https://github.com/jasondavies/d3-cloud",
"version": "1.0.5",
"_release": "1.0.5",
"_resolution": {
"type": "version",
"tag": "v1.0.5",
"commit": "83eb4128335eacdc0736ab7a6cafbdc2b124f484"
},
"_source": "https://github.com/jasondavies/d3-cloud.git",
"_target": "~1.0.5",
"_originalSource": "https://github.com/jasondavies/d3-cloud.git"
}
最佳答案
通常,您会以这种方式安装一些东西:
bower cache clean
bower install component --save
但是,如果添加的 repo 本身没有为 main 和 ignore 建立 bower.json 规则,您需要自己添加并 checkin 。
您可以通过以下方式做到这一点:
1.- Fork the original repository for the component
2.- Add a bower.json file.
3.- Include in this file a
"main": ['path/to/file'],
"ignore":['array','of','things','to','ignore']
3.-bower install your forked git repo, and it will work
关于node.js - grunt bower-install 填充的 bower 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30035618/