danielepiccone / ng-pageslide

AngularJS sliding panel for serving additional content from off the page
http://danielepiccone.github.io/ng-pageslide/examples/
452 stars 162 forks source link

Use this package with bower #136

Closed popod closed 8 years ago

popod commented 8 years ago

Not working when install with bower with error: "Uncaught Error: Cannot find module 'angular'"

danielepiccone commented 8 years ago

Why?

daniele ~/Documents/tmp$ bower install angular-pageslide-directive
bower angular-pageslide-directive#*       not-cached https://github.com/dpiccone/ng-pageslide.git#*
bower angular-pageslide-directive#*          resolve https://github.com/dpiccone/ng-pageslide.git#*
bower angular-pageslide-directive#*         checkout v2.1.1
bower angular-pageslide-directive#*         resolved https://github.com/dpiccone/ng-pageslide.git#2.1.1
bower angular#1.5.x                           cached https://github.com/angular/bower-angular.git#1.5.8
bower angular#1.5.x                         validate 1.5.8 against https://github.com/angular/bower-angular.git#1.5.x
bower angular-pageslide-directive#^2.1.1     install angular-pageslide-directive#2.1.1
bower angular#1.5.x                          install angular#1.5.8

angular-pageslide-directive#2.1.1 bower_components/angular-pageslide-directive
└── angular#1.5.8

angular#1.5.8 bower_components/angular
popod commented 8 years ago

In your case, that works because you have installed angular with npm. But if angular is installed with bower, this does not work.

    if (typeof define === 'function' && define.amd) {
        define(['angular'], factory);
    } else if (typeof module === 'object' && module.exports) {
        module.exports = factory(require('angular'));
    } else {
        factory(root.angular);
    }

In my case (angular and your package installed with bower), the second if statement is true and causes the error.. With the third statement, it will be ok.

I think you have an error in your second conditions ?

danielepiccone commented 8 years ago

Installing this module with bower installs angular as a dependency as well. This snippet is an UMD wrapper, which allows the module to be used within AMD, CommonJS and global environments. If you are using bower chances are you are using the AMD adapter (1st) or the global (3rd), the 2nd statement won't be true unless you are requiring this with node or another CommonJS environment.