Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Q 2.0.0 installed with Bower causes Uncaught ReferenceError: require is not defined

Tags:

bower

q

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.

like image 533
binarygiant Avatar asked May 15 '14 19:05

binarygiant


1 Answers

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.

like image 177
Kris Kowal Avatar answered Oct 11 '22 05:10

Kris Kowal