Foundation5导致grunt / bower构建错误

时间:2014-05-15 00:41:22

标签: gruntjs zurb-foundation bower bower-install

使用Grunt和bower构建项目时,Foundation似乎导致错误。您可以看到它下载包等,然后退出:

  

致命错误:无法找到适合jquery的版本

这是我的bower.json:

{
  "name": "MyProject",
  "version": "1",
  "dependencies": {
    "cytoscape": "2.2.7",
    "datatables": "1.9.4",
    "font-awesome": "4.0.3",
    "foundation": "5.2.2",
    "jquery-legacy": "jquery#1.11.0",
    "kineticjs": "5.1.0",
    "nouislider": "6.2.0",
    "rem-unit-polyfill": "1.2.4",
    "respond": ">=1.4.2"
  }
}

我尝试逐一从上面的bower.json中删除每个依赖项,然后每次重新运行我的grunt文件(其中包括一个bower安装的触发器)。我得到了这个错误,直到我删除了基础线 - 然后一切正常(好吧,直到Grunt找到基础文件)。

我已经查看过基金会的bower.json及其依赖项,但似乎并没有"似乎"不妥。

我试图为我的bower.json添加一个分辨率:

  ...,
  "resolutions": {
    "jquery": "1.11.0"
  }
}

但这并没有帮助。 (虽然我可能错误地使用了它?)

如果我从命令行直接尝试bower install,我会得到:

> Unable to find a suitable version for jquery, please choose one:
>     1) jquery#~1.8.0 which resolved to 1.8.3+1 and has datatables#1.9.4 as dependants
>     2) jquery#>= 2.1.0 which resolved to 2.1.1 and has foundation#5.2.2 as dependants
>     3) jquery#>=1.2 which resolved to 2.1.1 and has jquery.cookie#1.4.1 as dependants
>     4) jquery#>= 1.7.0 which resolved to 2.1.1 and has nouislider#6.2.0 as dependants
> 
> Prefix the choice with ! to persist it to bower.json
> 
> [?] Answer:

我可以在那里选择一个版本,它似乎有效。但是我需要在构建脚本中使用它。

1 个答案:

答案 0 :(得分:1)

尝试将jQuery更改为:

"jquery": "~1.11.0"

修改

根据基金会的bower.json,它声明它需要jQuery> = 2.1

{
  "name": "foundation",
  "version": "5.2.2",
  "main": [
    "css/foundation.css",
    "js/foundation.js"
  ],
  "dependencies": {
    "jquery": ">= 2.1.0",
    "modernizr": ">= 2.7.2",
    "fastclick": ">=0.6.11",
    "jquery.cookie": "~1.4.0",
    "jquery-placeholder": "~2.0.7"
  },
  "devDependencies": {
    "jquery.autocomplete": "devbridge/jQuery-Autocomplete#1.2.9",
    "lodash": "~2.4.1"
  },
  "private": true
}

2版本之间存在冲突。你改变了吗?