15

I am using Q in a project, and I am using bower to manage my JS dependencies. I am including Q 2.0.0 with bower in bower.json

"dependencies" : {
    "q": "~2.0.0"
}

In my index.html, I include Q with a script tag

<script src="bower_components/q/q.js"></script>

When I load the page, I see in the console:

Uncaught ReferenceError: require is not defined q.js:43

Line 43 of q.js:

require("collections/shim");

What am I missing here? Should I be using Browserify or require.js to get this to work? I expected the library to be accessible by simply using a tag.

binarygiant
  • 6,362
  • 10
  • 50
  • 73

1 Answers1

33

Bower is not very smart about selecting versions. As it happens, there is a 2.0 release train that is not compatible with Bower at all. You will want to install q#1.0.1 specifically.

Kris Kowal
  • 3,866
  • 2
  • 24
  • 24
  • Thanks, would it just be better to grab q from github and include it that way, so that I can use 2.0? – binarygiant May 15 '14 at 19:53
  • 4
    I don’t recommend using the v2 release train at this time, especially on Bower. It has not solidified enough for general use. – Kris Kowal May 24 '14 at 15:14
  • I hit the same issue. At first I thought q had a hard dependency on requriejs (which was puzzling) and went ahead requirifying my project only to discover this. #latenightcoding – Abhinav Gujjar Aug 22 '14 at 06:57
  • If you've come from the future: the current version at the time of this comment is 1.5.0. You can install via bower using `bower install --save q#1.5.0` – brendonofficial Apr 11 '17 at 07:28