sachinchoolur / ngclipboard

An angularjs directive to copy text to clipboard without using flash
http://sachinchoolur.github.io/ngclipboard/
MIT License
387 stars 93 forks source link

Doesn't Play Well With Bower #35

Open Kenkron opened 7 years ago

Kenkron commented 7 years ago

I'm using bower, and as expected, bower install ngclipboard --save installs ngclipboard, and it's dependency, clipboard. However, when loaded with these tags:

    <script type="text/javascript" src="./bower/angular/angular.js"></script>
    <script type="text/javascript" src="./bower/angular-aria/angular-aria.min.js"></script>
    <!--etc.-->
    <script type="text/javascript" src="./bower/clipboard/dist/clipboard.min.js"></script>
    <script type="text/javascript" src="./bower/ngclipboard/dist/ngclipboard.js"></script>

It produces this in the console:

WARNING: Tried to load angular more than once.
module.js:455 Uncaught Error: Cannot find module 'clipboard'

Referencing this code:

    // Check for CommonJS support
    if (typeof module === 'object' && module.exports) {
      angular = require('angular');
      Clipboard = require('clipboard');    //this line in particular
      module.exports = MODULE_NAME;
    } else {
      angular = window.angular;
      Clipboard = window.Clipboard;
    }

If I install using npm, it all works, even if I keep the bower source tags.

The project has node packages in the same directory, including angular, which explains why the log says WARNING: Tried to load angular more than once. instead of something like module.js:454 Uncaught Error: Cannot find module 'angular'.

hthetiot commented 7 years ago

See #37