Search code examples
javascriptangularjsbrowserify

requiring Angular with Browserify. 'Uncaught object' error


When I require the Angular library with Browserify, I get an 'Uncaught object' error in bundle.js. It seems like Browserify has a problem with the Angular library? All other required files work with no errors. Can someone help me solve this please?

In my index.js file I do this 'require('./angular');' Which works as expected and bundles the file. Below are screenshots of the console errors.

enter image description here From Console


Solution

  • Browserify is not your issue in this case. There is a misconception that you cannot use libraries with Browserify without shims. Actually you can. I use both Angular, and Angular-Route fetched via Bower with Browserify just fine.

    The uncaught object is an AngularJS error. More than likely due to incorrect dependancy loading. Several mentions with NgRoute on SO here, here, and here