快把我逼疯了。到目前为止,Bower+Grunt (通过约曼)一直是挫折感和浪费时间的主要来源。我只想让我的应用程序使用最新版本的jquery (2.1.0)。
bower list正确地将jQuery2.1.0报告为官方更新。
我运行了bower install --save jquery来更新上一个版本,而它做到了。
bower list命令现在正确地将jquery#2.1.0报告为依赖项,而bower.json文件现在正确地将所需版本的jquery列表为依赖项:
{
"name": "xxx",
"version": "0.0.0",
"dependencies": {
...
"angular": "1.2.13",
"jquery": "~2.1.0",
"sizzle": "1.10.16",
"bootstrap": "~3.0.3",
...但是每次我运行grunt build或grunt serve时,<script src="bower_components/jquery/dist/jquery.js"></script>列表都会从index.html中删除,从而阻止整个应用程序正常运行。
#> grunt serve
Running "serve" task
Running "clean:server" (clean) task
Cleaning .tmp...OK
Running "bower-install:app" (bower-install) task
jquery was not injected in your file.
Please go take a look in "app/bower_components/jquery" for the file you need, then manually include it in your file.
Running "concurrent:server" (concurrent) task
...手动添加并不能解决任何问题。我完全被困住了。这一定是我做错了什么,但我已经敲了很长一段时间了,但我完全没有效率。谢谢。
发布于 2014-02-18 20:09:55
这里有一个很长的答案,但我只有一个简短的时间,我想我还是给它而不是什么也不给!
bower-install是一个依赖于Bower包的任务,该包在其bower.json中正确地指定了一个main属性。最近,jQuery Bower包进行了一些操作,它不再指定此属性。没有它,grunt-bower-install就帮不了什么忙。
解决方案是在jQuery块之外手动包含对<!-- bower:js --><!-- endbower -->的引用。
抱歉让你受挫了。希望jQuery很快就能修复它的bower.json。
发布于 2014-09-12 20:16:30
这里有一个更好的解决方案,它不会强迫您将脚本标记从其他bower组件移开。您可以使用overrides部分(在https://github.com/ajaxorg/ace-builds/issues/20上找到)
将以下部分添加到项目的bower.json中
...
"overrides": {
"jquery": {
"main": "dist/jquery.js"
}
}发布于 2016-04-27 00:08:29
几分钟前我也看到了同样的问题。在我的例子中,“重写”解决方案不起作用。
grunt wiredep继续重新排序app/index.html中的条目。问题在于jquery在bower.json的依赖项部分中的位置。在我的例子中,jquery是bower.json中依赖项部分的第9个条目。
grunt wiredep 然后移动
<script src="bower_components/jquery/dist/jquery.js"></script>到app/index.html中的位置#9,即使我手动输入#1条目或使用了重写。
在我的例子中,jquery需要领先于角,这种重新排序在运行时扼杀了我的应用程序。
我在bower.json中的依赖项部分看起来像在之前的
"dependencies": {
"angular": "1.4.8",
"angular-animate": "^1.3.0",
"angular-aria": "^1.3.0",
"angular-cookies": "^1.3.0",
"angular-messages": "^1.3.0",
"angular-resource": "^1.3.0",
"angular-route": "^1.3.0",
"angular-sanitize": "^1.3.0",
"jquery": "^2.2.3",
},现在,它看起来是这样的(注意jquery是如何迁移到#1位置的)。
"dependencies": {
"jquery": "^2.2.3",
"angular": "1.4.8",
"angular-animate": "^1.3.0",
"angular-aria": "^1.3.0",
"angular-cookies": "^1.3.0",
"angular-messages": "^1.3.0",
"angular-resource": "^1.3.0",
"angular-route": "^1.3.0",
"angular-sanitize": "^1.3.0",
}我把它放在这里是为了让其他人可以使用这个解决方案,如果没有其他办法的话。
https://stackoverflow.com/questions/21862757
复制相似问题