node.js - grunt bower-install 填充的 bower 依赖项

标签 node.js gruntjs yeoman bower bower-install

我已经为我的应用程序安装了一些 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/

相关文章:

javascript - 使用 DES (Node.js) 将数据传递到 Cipher.update 时丢失数据

ruby - Windows 7 - 如何解决 “You need to have Ruby and Sass installed and in your PATH for this task to work” 警告?

javascript - 如何在目标目录路径中使用YAML前面的内容?

gruntjs - Yeoman 使用 "grunt"命令启动项目时出错

mysql - 在 Electron 应用程序: ER_NOT_SUPPORTED_AUTH_MODE中连接到mysql

ios - 使用服务器上的 Socket.IO-Client-Swift 和 Swift、Sails.js 订阅房间(套接字)时出现问题

javascript - Angular 页面不显示来自 Node 后端的 JSON 数据

gruntjs - Grunt watch - 检测任务的成功和失败

javascript - 未找到 Yeoman Angular 特征生成器 cdnify 任务

node.js - 如何以编程方式调用 yeoman 生成器?