0

在使用 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 的触发器)。在删除 Foundation 行之前,我会收到该错误 - 然后一切正常(好吧,直到 Grunt 查找基础文件)。

我查看了 Foundation 的 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:

我可以在那里选择一个版本,它似乎工作。但我需要这个在构建脚本中工作。

4

1 回答 1

1

尝试将 jQuery 更改为:

"jquery": "~1.11.0"

编辑

根据 Foundation 的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版本之间存在冲突。你改变了吗?

于 2014-05-15T06:24:38.617 回答