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

StackOverflow https://stackoverflow.com/questions/23687267

  •  23-07-2023
  •  | 
  •  

Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top