sebnukem sebnukem - 1 year ago 134
Javascript Question

bower or grunt keeps removing jquery from index.html

This is driving me crazy. So far Bower+Grunt (via Yeoman) has been a major source of frustration and a waste of time. All I want is my app to use the latest (2.1.0) version of jquery.

bower list
correctly reported jquery 2.1.0 as an official update.

I ran
bower install --save jquery
to update to the last version, which it did.

bower list
command now correctly reports
as a dependency, and
file now correctly lists jquery with the wanted version as a dependency:

"name": "xxx",
"version": "0.0.0",
"dependencies": {
"angular": "1.2.13",
"jquery": "~2.1.0",
"sizzle": "1.10.16",
"bootstrap": "~3.0.3",

But every time I run
grunt build
grunt serve
<script src="bower_components/jquery/dist/jquery.js"></script>
list gets removed from
, preventing the entire app from functioning.

#> 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

Adding it manually doesn't solve anything. I'm completely stuck. There must be something I am doing wrong but I've been banging my head for a long time while being completely unproductive. Thank you.

Answer Source

There's a long answer here, but I only have time for a short one, and I figured I might as well give that instead of nothing!

bower-install is a task that depends on Bower packages properly specifying a main property inside of their bower.json. Some recent stuff has gone on with the jQuery Bower package, and it no longer specifies this property. Without, grunt-bower-install can't help much.

The solution is to manually include that reference to jQuery outside of the <!-- bower:js --><!-- endbower --> block in your HTML.

Sorry for the frustration. Hopefully, jQuery will fix its bower.json soon.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download